repr(x) == repr(y) <=> x == y AND eval(repr(x)) == x

Chad Netzer cnetzer at
Fri Oct 18 22:21:28 CEST 2002

On Friday 18 October 2002 12:56, Chad Netzer wrote:

> Furthermore, a straightforward trick is to wrap your object in a single
> element tuple, and use that as the key.  It is a much *MUCH* better
> solution than monkeying with 'eval( repr( x ) )'.

   Well, upon further investigation, it appears this trick's main fault is 
that it is bollocks.  It won't work:

a = {}
b = {}
a[ (b,) ] = 1

I thought the above would work, but it seems not to.  Anyone care to explain 
why (I'm off to look in the reference manual, in the meantime.)


Chad Netzer
cnetzer at

More information about the Python-list mailing list