datastructures

Gandalf gandalf at geochemsource.com
Fri Jun 11 07:50:57 EDT 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:

http://docs.python.org/tut/tut.html

Particularly, this one for data structures:

http://docs.python.org/tut/node7.html

Best,

   G

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 ? 
>
>regards,
>KM
>
>  
>





More information about the Python-list mailing list