Package portage :: Package util :: Class cmp_sort_key
[hide private]

Class cmp_sort_key

source code

object --+
         |
        cmp_sort_key

In python-3.0 the list.sort() method no longer has a "cmp" keyword argument. This class acts as an adapter which converts a cmp function into one that's suitable for use as the "key" keyword argument to list.sort(), making it easier to port code for python-3.0 compatibility. It works by generating key objects which use the given cmp function to implement their __lt__ method.

Beginning with Python 2.7 and 3.2, equivalent functionality is provided by functools.cmp_to_key().

Nested Classes [hide private]
  _cmp_key
Instance Methods [hide private]
 
__init__(self, cmp_func)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__call__(self, lhs) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  _cmp_func

Inherited from object: __class__

Method Details [hide private]

__init__(self, cmp_func)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • cmp_func (callable which takes 2 positional arguments) - A cmp function.
Overrides: object.__init__