8 def __init__(self
, arg
):
12 return '<Coerce %s>' % self
.arg
14 def __coerce__(self
, other
):
15 if isinstance(other
, Coerce
):
16 return self
.arg
, other
.arg
18 return self
.arg
, other
21 def __init__(self
,arg
):
25 return '<Cmp %s>' % self
.arg
27 def __cmp__(self
, other
):
28 return cmp(self
.arg
, other
)
31 candidates
= [2, 2.0, 2L, 2+0j
, [1], (3,), None, Empty(), Coerce(2), Cmp(2.0)]
39 print 'cmp(%s, %s) => %s' % (a
, b
, sys
.exc_info()[0])
42 print "%s == %s" % (a
, b
)
44 print "%s != %s" % (a
, b
)
45 # Ensure default comparison compares id() of args
48 L
.insert(len(L
)//2, Empty())
51 if cmp(a
, b
) != cmp(id(a
), id(b
)):
52 print "ERROR:", cmp(a
, b
), cmp(id(a
), id(b
)), id(a
), id(b
)