comparison between non-comparable objects

Dave Angel d at davea.name
Tue Jan 8 01:03:30 EST 2013


On 01/08/2013 12:28 AM, Kelvin Li wrote:
> The language reference says:
>
> "...the choice whether one object [of built-in type] is considered
> smaller or larger than another one is made arbitrarily..."

When quoting some online source, please give a reference link. It took
me a while to find the following page with your quote in it:


http://docs.python.org/3.3/reference/expressions.html
<http://docs.python.org/3.3/reference/expressions.htm>
   in section "6.9  Comparisons"

> but that seems to be Python 2 behavior; Python 3 apparently raises a
> TypeError. Does the documentation need updating?
>

That sentence is correct in context.  The bullet items there are labeled
"Comparison of objects of the same type..."  And the particular bullet
also qualifies the type of the two objects being compared:   " Most
other objects of built-in types..."



Earlier in the same section, it considers the case of comparing objects
of DIFFERENT type.

.... while the <, >, >= and <= operators raise a TypeError
<http://docs.python.org/3.3/library/exceptions.html#TypeError> when
comparing objects of different types that do not implement these
operators for the given pair of types....


-- 

DaveA




More information about the Python-list mailing list