return '<Coerce %s>' % self
.arg
def __coerce__(self
, other
):
if isinstance(other
, Coerce
):
return self
.arg
, other
.arg
return '<Cmp %s>' % self
.arg
def __cmp__(self
, other
):
return cmp(self
.arg
, other
)
candidates
= [2, 2.0, 2L, 2+0j
, [1], (3,), None, Empty(), Coerce(2), Cmp(2.0)]
print 'cmp(%s, %s) => %s' % (a
, b
, sys
.exc_info()[0])
print "%s == %s" % (a
, b
)
print "%s != %s" % (a
, b
)
# Ensure default comparison compares id() of args
L
.insert(len(L
)//2, Empty())
if cmp(a
, b
) != cmp(id(a
), id(b
)):
print "ERROR:", cmp(a
, b
), cmp(id(a
), id(b
)), id(a
), id(b
)