Python newbie data structures question

codingJoe tracy.monteith at gmail.com
Thu Oct 29 07:31:54 CET 2009


Hi all!

I am trying to choose the right data structure to do a value lookup
with multiple keys.


I want to lookup data by:  key, key,{ values }

My final product should be able to reference this datastructure from
within a django template.


Because my lookup needs only 80 values and will never change, it seems
that I could just build some type of data structure or object.   My
rudamentary approach is to do lots of looping, but there must be a
better way to do this.

A dictionary object only has (key, value).  The same pair of keys
could return multiple values.
Tuples might work, but I just don't understand them enough.


the simple exampe is a quick lookup index the available sport by
season that returns one or many value.     The values would be data
structures and contain more than just the name, but also things like
uniform color, team size.

             indoors       outdoors
            -----------------------------------------------
winter   |  bball         |  skiing     |
            |                 |  sledding  |
            |----------------------------------------------
            |                  |  baseball |
summer|  raquetball  |  soccer    |
            |                  |               |
            |
            |----------------------------------------------

Advice?  What data structure should I use?  And a simple newbie
example please..



More information about the Python-list mailing list