[Zope] Python Q: dynamic dictionary of dictionaries..

zope@virtosi.com zope@virtosi.com
Mon, 5 Nov 2001 14:21:14 -0500 (EST)


this is more purely a python question as i am using external methods for 
most of my processing.... SOS,,, perl guy getting squeezed by the snake.

so this seems like it should be trivial but as a perl hack just learing, 
i'm not sure of the syntax, or if i am missing something basic about the 
dictionary type.

so, i have a list of strings that will be used as keys, say:  
>>> my_list['K1','K2','K3']

for each of those keys, i would like to create a dictionary that has as 
its value a dictionary that like  the following:

>>>test = {'us_lead': 0, 
>>>	'foreign_lead': 0, 
>>>	'us_gov_lead': 0,
>>>	'foreign_lead': 0, 
>>>	'us_other': 0, 
>>>	'foreign_other': 0 }

>>>for i in my_list:
>>>	hash_one = {i: ""}
>>>	hash_one[i] = test

this seems to "reset" the value of has_one with each iteration instead of 
updating it?? the key should be different, why is this??



-- thanks for all the love, 
james jackson (aka, jcj@slack.net)