lists and append, and loop iteration

Janko Hauser jhauser at ifm.uni-kiel.de
Wed Sep 22 05:02:52 EDT 1999


Is this what you want?

>>> d={}
>>> a=d.get('new_key',[])                    
>>> a.append('new_value')
>>> d['new_key']=a
>>> d
{'new_key': ['new_value']}
>>> 

The reference to a is necessary. But this should work like you want if 
I understand correctly

HTH
__Janko

-- 
  Institut fuer Meereskunde             phone: 49-431-597 3989
  Dept. Theoretical Oceanography        fax  : 49-431-565876
  Duesternbrooker Weg 20                email: jhauser at ifm.uni-kiel.de
  24105 Kiel, Germany




More information about the Python-list mailing list