Override property setter of base class in Python 3

Chris Angelico rosuav at gmail.com
Sun Sep 11 06:12:27 EDT 2016


On Sun, Sep 11, 2016 at 8:02 PM, Nagy László Zsolt <gandalf at shopzeus.com> wrote:
> But this solution almost defeats the purpose of properties. E.g. a
> property should look like an attribute, and its behaviour should be
> manipulated through its name (and not another special method that must
> be exposed to subclasses.)

Even the problem seems to rather defeat the purpose of a property. A
property should be very simple - why do you need to override it and
call super()? Doesn't this rather imply that you've gone beyond the
normal use of properties *already*?

Subclassing and overriding are part of the interface of a class,
albeit an interface that only a subset of other classes will use.
Think carefully about why, if this is meant to be made available, it
isn't simply a method call.

ChrisA



More information about the Python-list mailing list