What is up with "=="?

Terry Reedy tjreedy at udel.edu
Wed Oct 8 19:15:17 EDT 2003


"Quentin Crain" <czrpb at yahoo.com> wrote in message
news:mailman.1065646155.11498.python-list at python.org...
> 2  Why IS comparison supported across types?

There are only two simple rules: only compare within types; allow all
compares.  If two things are not equal, why not say so?

Besides history, consider the following intentional feature:
>>> 0 == 0L == 0.0 == 0+0j
1 #True in 2.3

One could also import a rational or fixed-point number module and if
their classes have the needed special method, add them to the list.

Also consider this:
>>> (0,1,2) == (0,1,'2')
0 # False in 2.3

Would you really want to get an exception rather than False?

Terry J. Reedy






More information about the Python-list mailing list