Skip to content

Instantly share code, notes, and snippets.

@staticshock
Created February 15, 2012 16:24
Show Gist options
  • Save staticshock/1837039 to your computer and use it in GitHub Desktop.
Save staticshock/1837039 to your computer and use it in GitHub Desktop.
#!/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