[ create a new paste ] login | about

Link: http://codepad.org/W9MI1IbO    [ raw code | output | fork ]

Python, pasted on Mar 23:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class TestableEq(object):
    def __init__(self):
        self.eq_run = False
    def __eq__(self, other):
        self.eq_run = True
        return True

eq1 = TestableEq()
eq2 = TestableEq()
eq3 = TestableEq()

print [eq1] == [eq2]
print eq1.eq_run
print eq2.eq_run

print [eq3] == [eq3]
print eq3.eq_run


Output:
1
2
3
4
5
True
True
False
True
False


Create a new paste based on this one


Comments: