Data Structure Question

Mike Johnson ffp_randjohnson at yahoo.com
Sun Jun 17 12:03:38 EDT 2001


Hello,
I searched for a day to answer this question on my own, but I didn't come
up with anything. (But I did learn some great things about Python :-)

I've been looking for the Python equivalent of a Perl hashed array. I
learned about dictionaries from the help, but they don't work in quite the
same way since my keys are not always unique.

I was hoping to do something like:

diction['thekey']=value

in a loop. The key and the value are not always unique, so 'diction' ends
up dropping some information.

On thing that did work was to embed a nested dictionary into a list.

list=[]
diction={}

diction['key']='somedata'
list.append(diction)
diction={}
(repeat)

But... This makes it a terrible pain to search and count keys....

I've no doubt been searching the help using the wrong terminology. Even if
you can point me to the right structure or module, it would be a big help.
(Nothing needs to be mutable.)

Thank you!

- Mike Johnson


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list