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

Ravi ra.ravi.rav at gmail.com
Sat Mar 5 12:43:55 EST 2011


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'

and if d[1] and d[1][abc] raise KeyError just create them.

for d[1] I can override __getitem__() but how to do the same for the d[1][abc]?



More information about the Python-list mailing list