Just stumble upon this, consider following code:
class A(object):
pass
class B(object):
pass
a = A()
b = B()
print a > b # False
The doc states:
If no
__cmp__(),__eq__()or__ne__()operation is defined, class instances are compared by object identity (“address”).
In above code the address of a and b were at runtime:
id(a) # >>> 4499550864
id(b) # >>> 4499682960
So it makes sense why the a > b yields False, as address of a is not greater than address of b?(Is this what's happening?) If we consider above conclusion, just changing the position of instance creation in above code still yields a > b as False:
b = B()
a = A()
assert id(a) > id(b) # doesn't raises assertion error
print a > b # >>> False (why still False??)
Why?? isn't address of a is now bigger than address of b? (I guess it is as assertion error was not raised.)