repr(x) == repr(y) <=> x == y AND eval(repr(x)) == x
thorsten at thorstenkampe.de
Sat Oct 19 16:30:33 CEST 2002
* Chermside, Michael
>> A wise man once said to me:
>> | You're FAR more likely to meet objects where you can't count on
>> | eval(repr(x)) == x, than non-hashable objects.
> Trust your wise friend.
He's not my friend but I trust anyone who knows Python better than
me. I was just curious, /why/ and /when/.
The "Python Cookbook" (17.3 Removing Duplicates from a Sequence,
Credit: Tim Peters) has a better approach: Try to use a dictionary, if
that fails because of non-hashable items, use a different algorithm
with a list instead.
More information about the Python-list