Tricky Areas in Python
Kent Johnson
kent37 at tds.net
Mon Oct 24 06:07:23 EDT 2005
Steven D'Aprano wrote:
> Alex Martelli wrote:
> Those two are easy. However, and this is where I show my hard-won
> ignorance, and admit that I don't see the problem with the property
> examples:
>
>> class Base(object)
>> def getFoo(self): ...
>> def setFoo(self): ...
>> foo = property(getFoo, setFoo)
>>
>> class Derived(Base):
>> def getFoo(self): ....
>
>
> Unless the answer is "Why are you using setters and getters anyway? This
> isn't Java you know."
>
> Oh wait! Yes I do... the setter doesn't actually take an argument to set
> the property too. Is that it, or have a missed a cunningly hidden deeper
> problem?
Derived.getFoo() will not override the use of Base.getFoo() to access the attribute foo.
Kent
More information about the Python-list
mailing list