[Python-Dev] Declaring setters with getters (original) (raw)
Steven Bethard steven.bethard at gmail.com
Thu Nov 1 03:43:20 CET 2007
- Previous message: [Python-Dev] Declaring setters with getters
- Next message: [Python-Dev] Declaring setters with getters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/31/07, Fred Drake <fdrake at acm.org> wrote:
If I had to choose built-in names, though, I'd prefer "property", "propset", "propdel". Another possibility that seems reasonable (perhaps a bit better) would be:
class Thing(object): @property def attribute(self): return 42 @property.set def attribute(self, value): self.ignored = value @property.delete def attribute(self): pass
+1 on this spelling if possible. Though based on Guido's original recipe it might have to be written as::
@property.set(attribute)
def attribute(self, value):
self._ignored = value
STeVe
I'm not in-sane. Indeed, I am so far out of sane that you appear a tiny blip on the distant coast of sanity. --- Bucky Katt, Get Fuzzy
- Previous message: [Python-Dev] Declaring setters with getters
- Next message: [Python-Dev] Declaring setters with getters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]