Since Python 2.x tried to make comparisons between objects of different types available (even if they don't make sense).
This has been fixed in Python 3:
>>> object() > 0
Traceback (most recent call last):
File "<pyshell#320>", line 1, in <module>
object() > 0
TypeError: unorderable types: object() > int()
The order used in Python 2.x is:
None < Numbers < [Other types in alphabetical order]
The numbers: int, booland float, but not complexbecause they can not be compared
In addition, objects from old-style classes (called instanceobjects) remain between Noneand Numbersfor some odd reason.
source
share