Skip to content

Instantly share code, notes, and snippets.

@realeroberto
Last active August 29, 2015 14:15
Show Gist options
  • Save realeroberto/408371e73387b5132610 to your computer and use it in GitHub Desktop.
Save realeroberto/408371e73387b5132610 to your computer and use it in GitHub Desktop.
A generic equality mixin in Python.
# Generic equality mixin
# http://stackoverflow.com/questions/390250/
class EqualityMixin(object):
def __eq__(self, other):
if type(other) is type(self):
return self.getX() == other.getX() and self.getY() == other.getY()
else:
return False
def __ne__(self, other):
return not self.__eq__(other)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment