Why doesn't this work ? For loop variable scoping ?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Fri Mar 20 08:34:58 EDT 2009
En Thu, 19 Mar 2009 19:33:36 -0300, Ryan Kelly <ryan at rfk.id.au> escribió:
>> newCylinderTempertature = newCylinderTemperature + deltaTemp
>
> Take a careful look at the variable name here: "Tempertature". Python's
> dynamic nature provides a lot of wonderful benefits, but you've just hit
> one of the drawbacks - you don't get any protection from typos in
> variable names.
There are some tools that mitigate the problem: pylint and pychecker would
emit a warning in this case ("name is used only once" or similar), and the
autocompletion feature -present in most IDE / specialized editors- avoids
one to re-type the name over and over.
--
Gabriel Genellina
More information about the Python-list
mailing list