This question is in the same context of my two earlier questions. This
question was raised by some python beginners, and I would like to check with
the list to ensure I provide a correct answer.
Here is a code snippet I used to demonstrate the keyword *property*:
self.__not_here = 1
def __set_not_here(self, v):
print "I am called"
self.__not_here = v
not_here = property(lambda self: self.__get_not_here(), lambda self, v:
# not_here = property(lambda self: self.__not_here, lambda self, v:
self.__not_here = v)
So the question: is it possible to use lambda expression at all for the
setter? (As in the last, commented-out line)
Python interpreter will throw an exception right there if I use the last
line ('SyntaxError: lambda cannot contain assignment'). I'd use pass a
setter method anyway.
What is your preferred solution?
Don?t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That?s giving your intelligence _much_ too much credit.
- Linus Torvalds
-------------- next part --------------
An HTML attachment was scrubbed...