declaration of variables?
André Jonsson
tatsujin at spamgoeshere.despammed.om
Sat Feb 15 12:05:09 EST 2003
Being a Python-n00b, in the midst of this ?: discussion, it occurred to me that
Python does not require variables be delcared before use.
Why is this so? Isn't it very helpful if the compiler complains rather than having
strange run-time results?
Small example:
if doStuff(42):
value=getNextValue()
else:
valeu=initialValue # <-- Note the spelling error.
Surely, in an elightened language like Python it shouldn't be possible to do this
kind of error without the compiler complaining.
The compiler.compileFile() function doesn't complain either, nor does pychecker seem
to. It's almost as if it was by design... is it?
/André
More information about the Python-list
mailing list