Want to add dictionary keys to namespace?

Jeff Jeffries jeff.jeffries.iii at gmail.com
Fri Nov 9 19:00:04 EST 2012


Smart people, Is there a way I can add a dictionaries keys to the python
namespace? It would just be temporary as I am working with a large
dictionary, and it would speed up work using an IDE.  I look and find
nothing... none of the keys have spaces and none are common names within
the module.

http://stackoverflow.com/questions/2597278/python-load-variables-in-a-dict-into-namespace

I do this:

#Do this?
dictionary = {"AppleSeed": None, "Has": None,"Horrible" :None,"Art"}
for key in dictionary.keys():
     eval("%s=None"%key)

#or do this?
locals().update(dictionary)

Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121109/2381bc25/attachment.html>


More information about the Python-list mailing list