I am trying to write Python properties with using less code, I'd like to define getter and setter functions with lambdas.
So, I try like this:
class Text(object):
content = property(lambda self: self._content,
lambda self,content: self._content = content)
def __init__(self, content):
self._content = content
pass
But unfortunately, I get error on second lambda expression (on setter), because you can't define lambda with assignment, right?
So is there some other way to writing a property (preferably inline) that would take less code. Private attribute _content is of type string, is there a way to assign a value to string without = operator.