Caleb Hattingh wrote:

> In what way is it unreliable?  I can't seem to create a situation where
> the update through globals and locals doesn't work.   Are you referring

Updates to a locals() dictionary may not be reflected by the variables in
the local scope, e. g.:

>>> def f():
...     locals()["a"] = 1
...     print a
...
>>> f()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 3, in f
NameError: global name 'a' is not defined
>>> def f():
...     a = 42
...     locals()["a"] = 1
...     print a
...
>>> f()
42

Updating globals() should be safe.
 
Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to