[Python-Dev] LOAD_NAME & classes
Jeremy Hylton
jeremy@zope.com
Tue, 23 Apr 2002 12:06:37 -0400
>>>>> "GvR" == Guido van Rossum <guido@python.org> writes:
GvR> Changing LOAD_FAST so that
GvR> x = 1
GvR> def f():
GvR> print x
GvR> x = 2
GvR> print x
GvR> prints 1 followed by 2 instead of raising UnboundLocalError
GvR> would not break existing code (except code relying on specific
GvR> exceptions to be raised -- but such code is always exempt from
GvR> non-breakage guarantees).
It wouldn't break existing code, but it would encourage the existence
of broken code. It's asking for trouble to write a function that uses
a local and a global with the same name. I don't think we should bend
the rules to accommodate this kind of confusion.
Jeremy