On Wed, 8 Dec 2004 20:22:52 -0500, Terry Reedy [EMAIL PROTECTED] wrote:
To respond to and summarize several posts in this discussion:
Within a function, where the local namespace is distinct from the global
(module) namespace, CPython usually implements the local namespace
internally as a
Steve,
I don't think I understand. Here is what I just tried:
' def f():
x = 3
d = locals()
print x
print d['x']
d['x'] = 5
print x
' f()
3
3
3
'
In your example, x had not yet been initialised, maybe. What I am seeing
is that x does not
Caleb Hattingh wrote:
Steve,
I don't think I understand. Here is what I just tried:
' def f():
x = 3
d = locals()
print x
print d['x']
d['x'] = 5
print x
' f()
3
3
3
'
In your example, x had not yet been initialised, maybe. What I am
seeing is that x does not seem
Steven Bethard wrote:
I remember hearing an explanation of why locals() is not writable that
had to do with something about efficiency and the call stack (or
something like that)...
IIRC, the function local namespace (in CPython) is kept internally as a
static array, rather than as a
To respond to and summarize several posts in this discussion:
Within a function, where the local namespace is distinct from the global
(module) namespace, CPython usually implements the local namespace
internally as a fixed-length array. When this is true, locals() is a
*copy* of the local