Comparing objects to built-in literals

R

Richard Hayden

-----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-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top