> If there were really such a thing as nested scopes/namespaces, we would 
> have a function that would give us access to them, similar to the way 
> that locals() and globals() give us access to the local and global 
> namespace.

It would be _convenient_ to have such a function for inspection, but it's 
not a requirement.

Here's a function that shows lexical scope in action:

##########################
>>> def pair(x, y):
...     def f(b):
...         if b: return x
...         return y
...     return f
...
>>> p = pair(3, 4)
>>> p(True)
3
>>> p(False)
4
##########################
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to