Python newbie data structures question
wuwei23 at gmail.com
Thu Oct 29 08:10:29 CET 2009
On Oct 29, 4:31 pm, codingJoe <tracy.monte... at gmail.com> wrote:
> I am trying to choose the right data structure to do a value lookup
> with multiple keys.
Is something like this what you're after?
>>> from collections import defaultdict
>>> sports = defaultdict(list)
>>> sports['outdoors','winter'] # note that the order of the items is important
(defaultdict is available in Python 2.5+)
Tuples are immutable (unmodifiable) objects, which allows you to use
them as dictionary keys. They're really not scary at all ;)
Hope this helps.
More information about the Python-list