Dictionaries with tuples or tuples of tuples

Mitya Sirenef msirenef at lightbird.net
Tue Feb 19 02:56:28 CET 2013


On 02/18/2013 08:38 PM, Jon Reyes wrote:
> Hi Mark. Well, doesn't  iteritems() work the same? or am I missing something? By the way I'm 
sure I read the dictionaries part of Python but I'm unsure if it would 
take int's as a key for dictionaries. I've been weaned on Java where the 
keys of hashmaps are always Strings.
 >
 > PS: Just checked, wow I could use ints as keys. Awesome!

In fact, any hashable object can be a key in a dict, so you can define
your own custom objects and use them as keys -- this can be
extremely useful sometimes!

  -m


-- 
Lark's Tongue Guide to Python: http://lightbird.net/larks/

Oaths are the fossils of piety.  George Santayana




More information about the Python-list mailing list