MCPcopy Index your code
hub / github.com/python/cpython / K

Class K

Lib/functools.py:208–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206def cmp_to_key(mycmp):
207 """Convert a cmp= function into a key= function"""
208 class K(object):
209 __slots__ = ['obj']
210 def __init__(self, obj):
211 self.obj = obj
212 def __lt__(self, other):
213 return mycmp(self.obj, other.obj) < 0
214 def __gt__(self, other):
215 return mycmp(self.obj, other.obj) > 0
216 def __eq__(self, other):
217 return mycmp(self.obj, other.obj) == 0
218 def __le__(self, other):
219 return mycmp(self.obj, other.obj) <= 0
220 def __ge__(self, other):
221 return mycmp(self.obj, other.obj) >= 0
222 __hash__ = None
223 return K
224
225try:

Callers 1

pdfFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected