In C, it is necessary to declare your variables at the
start of each function. Of course, Python has no
variable declarations, but I find it good practice to
intialize all of my variables at the start of each function
like so:
def foo():
#variable initializations:
s = ""
i = j = 0
################
for i in range(10):
for j in range(10):
s = str(i + j)
print s
That way I can quickly see which variables are being
used in the function. It organizes things more clearly for
me. And it helps keep track of what types variables are,
which IMO is useful in more complicated code.
It would be terrific if PyChecker could check for this;
that all variable initializations come before other
commands (analogous to a C compiler verifying that
declarations come first).
Thank you.
--Nick
Logged In: NO
My email is nicksjacobson at yahoo.com.