Talk:Python Programming/Dictionaries

There's nothing here on iterating over dictionaries, and I'm a Python beginner, so I'm throwing this out for discussion:

for key in dict: print key, dict[key]

How to add things to an existing dictionary is not mentioned. In my specific example: I want to add a key and definitiond for every member in a specific class, but this article makes it look like I'd different dictionaries for every member and only after that could I, in the darkness, bind them.--Hakusa 09:45, 3 September 2006 (UTC)


 * As far as I can see, adding is as simple as the_dict['some key'] = value. If you wanted to merge a dictionary:

for key in old_dict: merge_dict[key] = old_dict[key]
 * But obviously keys using the same name are overwritten. Ragzouken 23:57, 3 November 2006 (UTC)