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

Chris Rebert clp2 at rebertia.com
Mon Mar 7 03:30:24 EST 2011


On Sun, Mar 6, 2011 at 11:06 PM, Javier <nospam at nospam.com> 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"]=...
>
<snip>
> Does anybody have  another idea for representing tree-like data?  Is
> there another type for trees in python?

You see a tree, I see a database (http://docs.python.org/library/sqlite3.html ):

+--------------+---------+-----+-------+
| Manufacturer | Model   | MPG | Price |
+--------------+---------+-----+-------+
| Ford         | Taurus  | ... | $...  |
| Toyota       | Corolla | ... | $...  |
+--------------+---------+-----+-------+

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list