Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #24858
| From | eisoab@gmail.com |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | locals().update(...) |
| Date | 2012-07-04 04:56 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <451cfda5-3fe6-4066-94f3-31f4fe747233@googlegroups.com> (permalink) |
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
locals().update(...) eisoab@gmail.com - 2012-07-04 04:56 -0700
Re: locals().update(...) Christian Heimes <lists@cheimes.de> - 2012-07-04 14:14 +0200
Re: locals().update(...) Dave Angel <d@davea.name> - 2012-07-04 18:48 -0400
Re: locals().update(...) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-04 22:57 +0000
csiph-web