Skip to content

Instantly share code, notes, and snippets.

@pfreixes
Created March 30, 2016 08:35
Show Gist options
  • Select an option

  • Save pfreixes/d0a99f8b73247b26588a7c429bc74491 to your computer and use it in GitHub Desktop.

Select an option

Save pfreixes/d0a99f8b73247b26588a7c429bc74491 to your computer and use it in GitHub Desktop.
Immutable made easy with Python
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