Skip to content

Instantly share code, notes, and snippets.

@scoopseven
Created March 12, 2015 15:55
Show Gist options
  • Save scoopseven/1b0aeac4a3b89832f51e to your computer and use it in GitHub Desktop.
Save scoopseven/1b0aeac4a3b89832f51e to your computer and use it in GitHub Desktop.
def __eq__(self, other):
_NOTFOUND = object()
for attr in ['user', 'street', 'street2', 'city', 'region', 'zip', 'country']:
v1, v2 = [getattr(obj, attr, _NOTFOUND) for obj in [self, other]]
if v1 is _NOTFOUND or v2 is _NOTFOUND:
return False
elif v1 != v2:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment