Created
March 12, 2015 15:55
-
-
Save scoopseven/1b0aeac4a3b89832f51e 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
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