Extending dict (dict's) to allow for multidimensional dictionary
TomF
tomf.sessile at gmail.com
Mon Mar 7 11:35:50 EST 2011
On 2011-03-05 12:05:43 -0800, Paul Rubin said:
> 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'
Depends on the use cases. If you only want to access d by a full
tuple, that's fine. If you want to access all the entries below d[1],
it's a problem. And if you want to access entities randomly by an
arbitrary dimension, you probably want a database (as others have
pointed out).
-Tom
More information about the Python-list
mailing list