Namespace Mystery (HELP!)
Paul Prescod
paul at prescod.net
Fri Jul 7 00:57:41 EDT 2000
> Why is the output "2 1" and not "2 2"?
> What is it about the locals() function that makes it behave
> unexpectedly?
locals ()
Return a dictionary representing the current local symbol table.
Warning: the contents of this dictionary should not be modified; changes
may not affect the values of local variables used by the interpreter.
http://www.python.org/doc/lib/built-in-funcs.html
Python doesn't typically look up local variables based on a string name
at runtime. That would be too inefficient. Rather it looks them up
positionally.
--
Paul Prescod - Not encumbered by corporate consensus
Pop stars come and pop stars go, but amid all this change there is one
eternal truth: Whenever Bob Dylan writes a song about a guy, the guy is
guilty as sin.
- http://www.nj.com/page1/ledger/e2efc7.html
More information about the Python-list
mailing list