statically nested scopes
Paul Prescod
paulp at ActiveState.com
Sun Nov 5 13:23:48 EST 2000
On Sat, 4 Nov 2000, Robin Becker wrote:
> How can this work when different paths define different
> variables.
You're probing a dark corner of Python, but I don't think that
statically nested scopes makes it any worse than it is.
> ie
>
> G=0
> def A():
> for i in range(3):
> if i>=2:
> G=i*i
> def B():
> return G+2
> print B()
I claim the answer would be the same as if you remove the
nested function altogether:
G=0
def A():
for i in range(3):
if i>=2:
G=i*i
print G
A()
It is all figured out statically, not dynamically so G is either
always a local or always a global -- in this case always a local
because it is assigned to.
Paul Prescod
More information about the Python-list
mailing list