override a property

Robin Becker robin at SPAMREMOVEjessikat.fsnet.co.uk
Fri Oct 21 03:56:15 EDT 2005


Kay Schluehr wrote:
> Robin Becker wrote:
> 
> 
>>I thought that methods were always overridable.
>>In this case the lookup on the
>>class changes the behaviour of the one and only property.
> 
> 
> How can something be made overridable that is actually overridable? I
> didn't know how to better express the broken polymorphism of Pythons
> properties than by stating it as a pleonasm about the used get and set
> methods. This way a property don't ever have to be redefined in
> subclasses if get_x, set_x etc. are changed. 
> 
> Kay
> 

well I guess that's the ambiguity of human language. Clearly when I 
assign to a normal attribute I am changing its value; assigning to a 
property or descriptor does something that is not so obvious. Changing 
the behaviour of such an attribute could be done by inheritance as 
suggested. The new class has overridden the property. When I want to do 
that on an instance I have first to create a mutable version of the 
descriptor where the mutability is on the instance not the class. I call 
the action of changing the base descriptor behaviour 'overriding', but 
perhaps that's not the correct word. What do you suggest?
-- 
Robin Becker



More information about the Python-list mailing list