declaration of variables?

André Jonsson tatsujin at
Sat Feb 15 18:05:09 CET 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):
         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?


More information about the Python-list mailing list