datastructures

km km at mrna.tn.nic.in
Sat Jun 12 17:36:06 CEST 2004


hi all,
no no i want to create  something like this on the fly:

d = {key1: [array1],key2:[array2], key3:[array3]}

how to do this ? 

regards,
KM
--------------------------------------------------------
On Fri, Jun 11, 2004 at 01:50:57PM +0200, Gandalf wrote:
> 
> 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