Created
May 5, 2019 13:37
-
-
Save siroken3/65e13c3e60a2977b1de05ead9317ec36 to your computer and use it in GitHub Desktop.
immutable_class.py
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
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