On Thu, 2008-10-30 at 16:54 -0200, Jorge Peixoto de Morais Neto wrote: > > To back myself up: > > > > <file name="why_no.py"> > > #!/usr/bin/python > > > > import random > > > > for i in range(1,10000): > > if random.random() < 0.001: > > print "rare" > > if malformed < beast: > > print "kick me in the ..." > > else: > > print "whatever" > > </file> > This kind of error is not a syntax error; this kind of error is indeed > only discovered at runtime. However, syntax errors are discovered at > byte-compile time. byte-compile happens automatically when you load a > module, but you can perform it yourself easily, and this is > recommended in certain situations. > > For this kind of error (try to reference an undefined variable), there > are tools like pychecker. >
I'm coming into this thread kinda late, so feel free to ignore... ... but Jorge is right. This is easily picked up by a lint tool... and good python programmers use them ;-). Some python-aware editors even have this functionality built in. Using the above example: $ pylint who_no.py ... C: 1: Missing docstring C: 5: Comma not followed by a space for i in range(1,10000): ^^ E: 8: Undefined variable 'malformed' E: 8: Undefined variable 'beast'