View source on GitHub |
Helpers providing a bridge between the Python 2 __cmp__
and Python 3.
Python 2 uses methods called __cmp__
to override object comparison behavior;
in Python 3 __cmp__
is replaced by rich comparison functions.
Additionally, Python 2 allows code to compare objects of different types, falling back to lexographical class-name comparisons if types are different (so instance of "int" are always less than instances of "str").
This file offers some utilities to bridge the gap between Python 2 and 3.
Functions
cmp(...)
: Emulate Python 2 cmp in Python 3.
total_ordering_from_cmp(...)
: Class decorator that fills in missing ordering methods from __cmp__
.