[Edu-sig] testing identitycheck.py
kirby urner
kirby.urner at gmail.com
Sat Jul 1 01:38:50 CEST 2006
"""
So I wanted to test "handedness" in Python, around operators,
by equating two different instances, each of different parentage.
One sees they're the same, the other begs to differ.
IDLE 1.1
>>> from identitycheck import testit
>>> testit()
a == b? False
b == a? True
Original context: a thread on the Math Forum:
http://mathforum.org/kb/message.jspa?messageID=4866533&tstart=0
>>>
"""
class A:
"""
Begs to differ
"""
def __eq__(self, other):
return False
class B:
"""
I see we're the same
"""
def __eq__(self, other):
return True
def testit():
a = A()
b = B()
print "a == b? ", a==b
print "b == a? ", b==a
if __name__ == "__main__":
testit()
More information about the Edu-sig
mailing list