Skip to content

Instantly share code, notes, and snippets.

@siroken3
Created May 5, 2019 13:37
Show Gist options
  • Save siroken3/65e13c3e60a2977b1de05ead9317ec36 to your computer and use it in GitHub Desktop.
Save siroken3/65e13c3e60a2977b1de05ead9317ec36 to your computer and use it in GitHub Desktop.
immutable_class.py
import collections
class Immutable (
collections.namedtuple('Immutable', [
'var1',
'var2',
'var3',
])
):
# Avoid using dict to store fields as namedtuple docs
slots = ()
@property
def sum(self):
return self.var1 + self.var2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment