On Oct 29, 4:31 pm, codingJoe <tracy.monte...@gmail.com> wrote: > I am trying to choose the right data structure to do a value lookup > with multiple keys.
Hey Joe, Is something like this what you're after? >>> from collections import defaultdict >>> sports = defaultdict(list) >>> sports['winter','indoors'].append('bball') >>> sports['winter','outdoors'].append('skiing') >>> sports['winter','outdoors'].append('sledding') >>> sports['summer','indoors'].append('raquetball') >>> sports['summer','outdoors'].append('baseball') >>> sports['winter','outdoors'] ['skiing', 'sledding'] >>> 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. -- http://mail.python.org/mailman/listinfo/python-list