David Isaac wrote:
> Le mercredi 06 septembre 2006 16:33,  Alan Isaac a écrit :
>>> Suppose a class has properties and I want to change the
>>> setter in a derived class. If the base class is mine, I can do this:
>>> http://www.kylev.com/2004/10/13/fun-with-python-properties/
>>> Should I? (I.e., is that a good solution?)
> 
> "Maric Michaud" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Why not ? This ontroduce the notion of public getter a la C++/Java while
> the
>> property is overloadable by itself (as below), but it's correct design
> IMHO.
> 
> More support for lambda, it seems...

Well, lambda's not going away[1], but there's no *need* for lambda here. 
  It could be written as::

     class Base(object):
         def __init__(self):
             self.foo = None

         def getFoo(self):
             return self.__foo

         def setFoo(self, val):
             self.__foo = val

         def _prop_get_foo(self):
             return self.getFoo()

         def _prop_set_foo(self, val):
             return self.setFoo(val)

         foo = property(fget=_prop_get_foo, fset=_prop_set_foo)

[1] http://www.python.org/dev/peps/pep-3099/

STeVe
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to