[Python-Dev] PEP 318: Properties (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Sat Apr 3 11:15:40 EST 2004
- Previous message: [Python-Dev] PEP 318: Let's propose some useful built-in decorators
- Next message: [Python-Dev] PEP 318: Properties
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
I'm still torn whether to promote defining properties this way:
[propget] def x(self): "Doc string for x" _return self.x [propset] def x(self, newx): _self.x = newx [propdel] def x(self): _del self.x but if people like this (whatever the decorator syntax :) we might as well make this the recommended way to define properties.
Does that actually work? I.e. is there an implementation of propget, propset, propdel so that this code introduces a property x?
My understanding is that above syntax would be short for> [propget] def x(self): "Doc string for x" return self.__x x = propget(x)
def x(self, newx):
self.__x = newx
x = propset(x)
def x(self):
del self.__x
x = propdel(x)Later assignments to x would override earlier ones, so that only the propdel survives.
Regards, Martin
- Previous message: [Python-Dev] PEP 318: Let's propose some useful built-in decorators
- Next message: [Python-Dev] PEP 318: Properties
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]