|
|
| Has anyone run into trouble using python dictionaries and having duplicate entries? |
| kadamat, dicts can only have one value associated with any given key (but that value can be a list, if you so wish) |
| Yes, that is how it is supposed to work But how are the keys compared? |
| kadamat, by hash and by ==. |
| 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 |
| kadamat, are you printing the repr() of the keys? |
| No, just the key itself as returned from the k,v iter_items |
| kadamat, are you sure the dupes are actually dupes? Can you give an example of two keys, as printed, that you think are dupes? |
| 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 |
| 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. |
| Hmm, okay, why should that make a difference though Okay ... |
| kadamat, well, for one, I can't see whitespace in that paste :) |
| There is a tab in the middle, but only one Key = "\t".join((record[0],record[1])) |
| kadamat, regardless of how you store the key, print repr(key) instead of the key directly. |
| Thanks :-) |