redho home | products | services
Web Design Forums

Web Design Forums  


Web Hosting, Web Design, Software and Web Development Forums  
 FAQFAQ   MemberlistArchive  Log inLog in   RegisterRegister 
         

trouble with using python dictionaries


Goto page 1, 2  Next
 
Post new topic   Reply to topic    Web Design Forums -> Python programming forum
View previous topic :: View next topic  
Author Message
kadamat



Joined: 01 Jun 2006
Posts: 88
Has anyone run into trouble using python dictionaries and having duplicate entries?
  Reply with quote


Gladis



Joined: 24 May 2006
Posts: 108
kadamat, dicts can only have one value associated with any given key (but that value can be a list, if you so wish)
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
Yes, that is how it is supposed to work
But how are the keys compared?
  Reply with quote
Gladis



Joined: 24 May 2006
Posts: 108
kadamat, by hash and by ==.
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
Like of the key is a string, how to I make sure it is checking by value
Hmm, okay then I have a problem here
I read in a file of triples
Compose a key using the first two items and insert it into a dictionary using the third as the value
  Reply with quote
Gladis



Joined: 24 May 2006
Posts: 108
kadamat, are you printing the repr() of the keys?
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
No, just the key itself as returned from the k,v iter_items
  Reply with quote
Gladis



Joined: 24 May 2006
Posts: 108
kadamat, are you sure the dupes are actually dupes? Can you give an example of two keys, as printed, that you think are dupes?
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
N::\en\@eng:aaron:baddeley||Aaron Baddeley]] [[N::\en\@eng:gregory:havret||Gregory Havret]] 2
[[N::\en\@eng:aaron:baddeley||Aaron Baddeley]] [[N::\en\@eng:gregory:havret||Gregory Havret]] 2
  Reply with quote
Gladis



Joined: 24 May 2006
Posts: 108
kadamat, are you assembling a string out of two strings and using that as key? I suggest using a tuple of the two strings, instead.
or, if you are doing that, use repr(key) instead of whatever you're using now to make them into something printable.
  Reply with quote
Page 1 of 2 Goto page 1, 2  Next
Post new topic   Reply to topic    Web Design Forums -> Python programming forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group