Comparing objects to built-in literals

Richard Hayden rah03 at nospam.doc.ic.ac.uk
Fri Mar 11 15:45:37 EST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Let's say I have a class which does not define __cmp__ or any of the
rich comparison functions and let x be an instance of this class, then
if I do:

x < 2
or x < ['hello']

I get True everytime. Now, I know that when no __cmp__ etc. is defined,
comparison of objects is done on identity (i.e. address), but what is
going on with literals like in these cases?

Thanks,

Richard Hayden.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCMgNw1y4M4bx2DkwRAusqAJ41770hdItCwSX4GZ4IfqWGFyY8dQCbBDaq
qPV1cZUrCnapcCY+driN2jU=
=9HT3
-----END PGP SIGNATURE-----



More information about the Python-list mailing list