On 09/18/2012 10:50 PM, weissman.m...@gmail.com wrote: > Well there's wired stuff like this: > > In [1]: locals()["x"] = 5 > > In [2]: print x > 5 >
No, there isn't. Modifying the dictionary returned by locals() has no effect. >>> def f (): ... locals()["x"] = 1 ... return x ... >>> f () Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in f NameError: global name 'x' is not defined >>> >>> locals()["x"] = 1 >>> x 1 >>> #this works because ... locals() is globals() True >>> The exception is the case when local scope is identical to global scope. In this case, locals() has globals() semantics. -- http://mail.python.org/mailman/listinfo/python-list