[Python-Dev] Declaring setters with getters

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Oct 31 23:48:43 CET 2007

Guido van Rossum wrote:
>     @property
>     def encoding(self):
>         return self._encoding
>     @propset(encoding)
>     def encoding(self, value=None):
>         if value is not None:
>             unicode("0", value)  # Test it
>         self._encoding = value

That's reasonably nice, although I'm not sure about the
name "propset" -- it sounds like a repair kit for an
aircraft. Maybe something like "setproperty" would be

But there's something that bothers me about the whole
propery mechanism -- there's no straightforward way for
a property accessor to call the inherited version from
a base class.

Wrapping property accessors up in decorators makes this
worse. At least when the accessors are declared as separate
functions you have a chance of grabbing an inherited one
and calling it. But if they're buried inside property
descriptors with no other reference to them, it's a lot
harder to get hold of one.


More information about the Python-Dev mailing list