[Tutor] scoping oddity

Bob Gailer bgailer at alum.rpi.edu
Sun May 8 01:17:31 CEST 2005


At 09:22 AM 5/7/2005, Brian van den Broek wrote:
>[snip]
>
>global will indeed fix that, yes. But, I've been lead to believe that
>one's first thought when tempted to write a global statement should be
>to reflect on whether that temptation isn't the symptom of a
>sub-optimal design. It certainly can (in my case has) lead to bugs
>when two separate bits of code both declare the same name global and
>thus each make their changes to it, after I have forgotten that I made
>both functions declare the name global.

Yes I agree. I was pondering this as I wrote my "reply". For quick and 
dirty programming global can save the day. For anything intended to be 
larger, more permanent I usually advocate use of classes.

[snip]

Bob Gailer
mailto:bgailer at alum.rpi.edu
510 558 3275 home
720 938 2625 cell  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050507/4d4f30c3/attachment.htm


More information about the Tutor mailing list