[Python-Dev] Declaring setters with getters (original) (raw)
Guido van Rossum guido at python.org
Thu Nov 1 00:02:23 CET 2007
- Next message: [Python-Dev] Declaring setters with getters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/31/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
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 better.
I'm open for a naming contest.
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.
Isn't there? You can just use super() ISTR, though I haven't had the need myself and don't recall the exact syntax.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Next message: [Python-Dev] Declaring setters with getters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]