On Nov 24, 4:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sat, 24 Nov 2007 01:55:38 -0800, samwyse wrote: > > I've had the same thought, along with another. You see, on of my pet > > peeves about all OO languages that that when creating new code, I > > generally begin by writing something like this: > > > cat = 'felix' > > dog = 'rover' > > def example(): > > global cat, dog # not always required, but frequently needed > > return ', '.join((cat, dog)) > > Ouch that's bad design IMHO. The need to use ``global`` is a design > smell, if needed *frequently* it starts to stink.
I'm not sure what you mean. In the example that I gave, the 'global' statement isn't needed. However, here's a different example: >>> top_score = 0 >>> def leaderboard(my_score): if my_score > top_score: print "A new high score!" top_score = myscore print "Top score:", top_score Traceback (most recent call last): File "<pyshell#49>", line 1, in <module> leaderboard(7, 'samwyse') File "<pyshell#47>", line 2, in leaderboard if my_score > top_score: UnboundLocalError: local variable 'top_score' referenced before assignment -- http://mail.python.org/mailman/listinfo/python-list