[Tutor] Re: creating variables from the 'key' of a dictionary. (original) (raw)
Andrei project5 at redrival.net
Fri Jul 2 15:42:13 EDT 2004
- Previous message: [Tutor] creating variables from the 'key' of a dictionary.
- Next message: [Tutor] Pickling objects and then carrying on development
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Larry Blair wrote on Fri, 2 Jul 2004 10:16:54 -0700:
> _My question is there a way to create a variable with the name of the key in_ > _a dictionary i.e._ >> _para = {}_ > _para['sourceserver'] = 'cm05'_ >> _at this point I want to create a variable with the name sourceserver and a_ > _value of 'cm05'._Use the globals() dictionary (it contains a dictionary mapping all variable names to corresponding objects):
globals()['sourceserver'] = 'cm05' sourceserver 'cm05'
But I think Jeff's suggestions for a settings module shared by all your apps is a better idea.
-- Yours,
Andrei
===== Real contact info (decode with rot13): cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP.
- Previous message: [Tutor] creating variables from the 'key' of a dictionary.
- Next message: [Tutor] Pickling objects and then carrying on development
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]