Multidimensional Dictionaries: Possible?

Darrell darrell at dorb.com
Mon Jan 24 20:22:09 EST 2000


[Tim Peters]
> Note too that you can use dict[key1, key2, ...] to "fake" a
multidimensional
> dict.  Sometimes that's more appropriate.  The equivalent in Perl
> interpolates the multiple subscripts into a string; Python's dicts are
more
> general (can be indexed by any immutable object, not just strings), and
> Python constructs a *tuple* of keys under the covers.  That's faster and
> can't suffer accidental "superkey" collisions.

Cool!

>>> d={}
>>> d[1,2]=12
>>> d[1,2]
12
>>> d[1,2,3,4,5,6]='hugeDimension'
>>> d[1,2,3,4,5,6]
'hugeDimension'
>>> d.keys()
[(1, 2), (1, 2, 3, 4, 5, 6)]
>>>

Now I just need a reason to do this :-/

The rumor was that you're fiscal manifestation might be sited at the
conference.
Can you assign a probability to this ?

--Darrell





More information about the Python-list mailing list