On Wed, 04 Jul 2012 18:48:08 -0400, Dave Angel wrote:
> As i said above, the rules are different for globals, and they are even
> if you use locals() to access them. However, i'd consider it prudent
> never to assume you can write to the dictionary constructed by either
> the locals() or the glob
On 07/04/2012 07:56 AM, eis...@gmail.com wrote:
> I expected this to work:
>
>
> def f(**args):
> locals().update(args)
> print locals()
> print a
>
> d=dict(a=1)
>
> f(**d)
>
> but:
>> global name 'a' is not defined
> Wher
Am 04.07.2012 13:56, schrieb eis...@gmail.com:
> I expected this to work:
It doesn't work and that's documented:
http://docs.python.org/library/functions.html?highlight=locals#locals
--
http://mail.python.org/mailman/listinfo/python-list
I expected this to work:
def f(**args):
locals().update(args)
print locals()
print a
d=dict(a=1)
f(**d)
but:
> global name 'a' is not defined
Where is my mistake?
This does work:
globals().update({'a':1})
print a
1
-E
--
http://mail.python.org/