On Thu, 06 Sep 2007 03:31:43 +0000, Alan Isaac wrote: >> Their only flaw is that they are not >> "virtual" (in C++ speak). In other words, you can't pass a "self" >> parameter to them. > > http://www.kylev.com/2004/10/13/fun-with-python-properties/
I'm not 100% sure I get what problem that piece of code is supposed to solve, but if I have understood it, the obvious solution is to use inheritance, not nasty tricks with lambdas. class Base(object): _foo = None def getFoo(self): return self._foo def setFoo(self, val): self._foo = val foo = property(getFoo, setFoo) class Derived(Base): # like Base, but the default for foo is 0 not None _foo = 0 (Naturally the above is a toy example -- for something as simple as that, there is no benefit in using properties.) The blogger who wrote it says "I was pretty impressed with myself for figuring this out. So I’m putting it on my site to pat myself on the back." Hmmm. Unless I've missed something, the solution on the web-page falls squarely in the too-clever-by-half bucket and nothing to be self- congratulatory about. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list