Created
March 30, 2016 08:35
-
-
Save pfreixes/d0a99f8b73247b26588a7c429bc74491 to your computer and use it in GitHub Desktop.
Immutable made easy with Python
This file contains hidden or 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
| class ImmutableRecord(object): | |
| def __init__(self, name): | |
| self.__name = name | |
| @property | |
| def name(self): | |
| return self.__name | |
| def __hash__(self): | |
| return hash(self.__name) | |
| def __eq__(self, b): | |
| return self.__name == b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment