Gandalf gandalf at
Fri Jun 11 13:50:57 CEST 2004

To create a dict:

d = { 'key1' : 'value1',  'key2' : 'value2' }

d['key1']       # evaluates to 'value1'
d['key2']       # evaluates to 'value2'
d['test']         # raises a KeyError exception

Please also note that a dictionary is an object, it has many methods 
like d.keys, d.values, d.has_key etc.
There is no array type in Python but there are higher level data 
structures: list, tuple, dictionary and set.

It seems you have not read the tutorial, did you?
Please visit this link:

Particularly, this one for data structures:



km wrote:

>hi all,
>how to create hash of an array in python as exists in perl ? 
>how abt dict of dicts ? 
>array of dicts etc ? 

More information about the Python-list mailing list