Multidimensional Dictionaries: Possible?

Richard Brodie R.Brodie at rl.ac.uk
Tue Jan 25 05:08:50 EST 2000


"Jerry Gardner" <w6uv at hotmail.com> wrote in message news:slrn88ppsg.49t.w6uv at voyager.home.com...
>
> Are multidimensional dictionaries possible in Python? I'm sure they're
> possible, but I can't figure out the syntax.

Indeed so. When you get the hang of it is actually easier to follow
than Perl's reference syntax.

> Here's how I do it in Perl:
<snipped - because it brings back painful previous Perl programs>

>>> dict={}
>>> dict['key1'] = {}
>>> dict['key1']['key2'] = 'thing'
>>> dict['key1']['key2']
'thing'
>>> dict
{'key1': {'key2': 'thing'}}

Hence in one:
>>> dict2 = {'key1': {'key2': 'thing'}}






More information about the Python-list mailing list