Creating Unique Dictionary Variables from List
gregcorradini at gmail.com
Wed Apr 11 22:01:47 CEST 2007
Your help is much appreciated. I will give this a try tomorrow morning and
get back on how it works.
Bruno Desthuilliers wrote:
> Greg Corradini a écrit :
>> Hello All,
>> I'm attempting to create multiple dictionaries at once, each with unique
>> variable names. The number of dictionaries i need to create depends on
>> length of a list, which was returned from a previous function.
>> The pseudo code for this problem would be:
>> returnedlist = [x,y,z]
>> count = 0
>> for i in returnedlist:
>> if count < len(returnedlist):
>> # then create a dictionary (beginning with variable dic) for each
>> with a unique name such that
>> # my unique name would be dic + count
>> Any ideas about this?
> Yes : use a dict to store your dicts:
> returnedlist = [x,y,z]
> dicts = dict()
> for num, item in enumerate(returnedlist):
> dicts['dict%s' % num] = dict()
View this message in context: http://www.nabble.com/Creating-Unique-Dictionary-Variables-from-List-tf3560643.html#a9947284
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list