jcarlson at nospam.uci.edu
Thu Mar 18 22:34:42 CET 2004
> One way to avoid this problem is to have an explicit scope-creating
> construct instead.
> def foo(a):
> scope outer:
> a = 3
> scope inner:
> a = 4
> print a # prints 4
> print outer.a # prints 3
> print foo.a # prints the function parameter
> print a # inner.a is out of scope, so prints 3
> foo.b = 5 # Creates a new function-scope variable.
> print b # prints 5
Ick. Thank god Python doesn't seem to be heading in this direction.
More information about the Python-list