I have smth like this:
class X():
def __init__(self):
self.__name = None
def _process_value(self, value):
# do smth
pass
def get_name(self):
return self.__name
def set_name(self, value):
self.__name = self._process_value(value)
name = property(get_name, set_name)
Can I replace get_name and set_name using lambda functions?
I've tried this:
name = property(lambda self: self.__name, lambda self, value: self.__name = self.process_value(value))
but compiler doesn't like my setter function.