lists and append, and loop iteration

Fredrik Lundh fredrik at pythonware.com
Wed Sep 22 06:13:44 EDT 1999


Janko Hauser <jhauser at ifm.uni-kiel.de> wrote:
> I could not write
> >>> dict={}
> >>> dict['new_key'] = dict.get('new_key',[]).append(['new_value'])
> >>> dict
> {'new_key': None}
> 
> To this refered my last note about the reference of a. Although I do
> not understand this. If I get not an empty list, why can I do an
> append?

"get" returns an empty list, "append" returns None.

</F>





More information about the Python-list mailing list