change property after inheritance
steven.bethard at gmail.com
Thu Sep 7 23:48:41 CEST 2006
George Sakkis wrote:
> Steven Bethard wrote:
>> 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:
>>>>> Should I? (I.e., is that a good solution?)
>>> "Maric Michaud" <maric at aristote.info> wrote in message
>>> news:mailman.82.1157557490.5279.python-list at python.org...
>>>> Why not ? This ontroduce the notion of public getter a la C++/Java while
>>>> property is overloadable by itself (as below), but it's correct design
>>> More support for lambda, it seems...
>> Well, lambda's not going away, but there's no *need* for lambda here.
>> It could be written as::
> Sure, it *could*; whether it *should* is a different issue. I can't
> imagine a case for absolute *need* of lambda, but there are several
> cases where it is probably the best way, such as the one of this
I'd contend that the "right" solution in this particular case is to use
a descriptor that creates a property with late-binding lookup. That way
you don't even need the extra function call that the lambda is
providing. Try using one of the following recipies:
That's not to say that there aren't other situations where a lambda
might be the best solution.
More information about the Python-list