[EMAIL PROTECTED] wrote: > Hello. Please tell me whether this feature request is sane (and not > done before) for python so it can be posted to the python-dev mailing > list. I should say first that I am not a professional programmer with > too much technical knowledge. > > I would like to have something like the "option explicit" statement in > Visual Basic which turns on C-like checking for declaration of > variables. This is highly helpful for people who are coming from C/C+ > +, for people who are learning programming using Python, and even > professionals, since this helps prevent typo errors like: > > sunlognitude = sunlongitude + 180.0 > > where the user has inadvertantly typed "g" before "n" and will later > wonder why his application is not working as expected. >
Just as a side-note, if you used a+=1 instead of a=a+1 then you wouldn't have this problem. Languages like Perl and VB need a strict mode because they will auto-vivify variable for you. I.e. they will bring variables to life with defined or undefined values if you use them in a l-value (left hand side of an assignment) without having declared them prior. If you do that in Python you get an exception. -- http://mail.python.org/mailman/listinfo/python-list