I couldn\'t find documentation on an equivalent of Java\'s final
in Python, is there such a thing?
I\'m creating a snapshot of an object (used for restorati
you can simulate something like that through the descriptor protocol, since it allows to define reading and setting a variable the way you wish.
class Foo(object):
@property
def myvar(self):
# return value here
@myvar.setter
def myvar(self, newvalue):
# do nothing if some condition is met
a = Foo()
print a.myvar
a.myvar = 5 # does nothing if you don't want to