Extending dict (dict's) to allow for multidimensional dictionary

John Nagle nagle at animats.com
Sat Mar 5 17:59:16 EST 2011


On 3/5/2011 12:05 PM, Paul Rubin wrote:
> Ravi<ra.ravi.rav at gmail.com>  writes:
>> I can extend dictionary to allow for the my own special look-up
>> tables. However now I want to be able to define multidimensional
>> dictionary which supports look-up like this:
>>
>> d[1]['abc'][40] = 'dummy'
>
> Why do that anyway?  You can use a tuple as a subscript:
>
>     d[1,'abc',40] = 'dummy'

    Also, at some point, it's time to use a database.
If you find yourself writing those "dictionaries" to
files, or trying to look up everything with "abc"
in the second subscript, a database is appropriate.

				John Nagle




More information about the Python-list mailing list