Created
February 15, 2012 16:24
-
-
Save staticshock/1837039 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
class Test(object): | |
def __init__(self, a): | |
self.a = a | |
def __eq__(self, other): | |
print "__eq__(%i, %i)" % (self.a, other.a) | |
return self.a == other.a | |
def __ne__(self, other): | |
print "__ne__(%i, %i)" % (self.a, other.a) | |
return not (self == other) | |
>>> [Test(1)] == [Test(2)] | |
__eq__(1, 2) | |
False | |
>>> [Test(1)] != [Test(2)] | |
__eq__(1, 2) | |
True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment