On 7 Mar, 09:30, Chris Rebert wrote:
> You see a tree, I see a database
> (http://docs.python.org/library/sqlite3.html):
>
> +--+-+-+---+
> | Manufacturer | Model | MPG | Price |
> +--+-+-+---+
> | Ford | Taurus | ... | $... |
>
On 2011-03-05 12:05:43 -0800, Paul Rubin said:
Ravi 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 us
On Sun, Mar 6, 2011 at 11:06 PM, Javier wrote:
> Looks a good idea. I use this kind of "recursive dicts" to represent
> tree like datastruct in python. Like:
>
> car["ford"]["taurus"]["price"]=...
> car["toyota"]["corolla"]["mpg"]=...
> car["toyota"]["corolla"]["price"]=...
>
> Does anybody hav
Looks a good idea. I use this kind of "recursive dicts" to represent
tree like datastruct in python. Like:
car["ford"]["taurus"]["price"]=...
car["toyota"]["corolla"]["mpg"]=...
car["toyota"]["corolla"]["price"]=...
It would be good if it could be combined with class2dict (converting
dict elem
That's a very nice suggestion. Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
On 3/5/2011 12:05 PM, Paul Rubin wrote:
Ravi 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 tupl
Ravi 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]
Ravi wrote:
> I found a solution here:
>
> http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-
dictionaries-in-python/
>
> Please tell how good is it?
Follow the link to the cookbook and read Andrew Dalke's comment ;)
To spell it out:
>>> class D(dict):
... def __missing_
I found a solution here:
http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/
Please tell how good is it?
--
http://mail.python.org/mailman/listinfo/python-list
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__
10 matches
Mail list logo