[Python-Dev] Declaring setters with getters
Duncan Booth
duncan.booth at suttoncourtenay.org.uk
Fri Nov 2 11:22:13 CET 2007
More information about the Python-Dev mailing list
Fri Nov 2 11:22:13 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 ]
Greg Ewing <greg.ewing at canterbury.ac.nz> wrote: > Fred Drake wrote: >> @property >> def attribute(self): >> return 42 >> >> @property.set >> def attribute(self, value): >> self._ignored = value > > Hmmm... if you were allowed general lvalues as the target of a > def, you could write that as > > def attribute.set(self, value): > ... > Dotted names would be sufficient rather than general lvalues. I like this, I think it looks cleaner than the other options, especially if you write both getter and setter in the same style: attribute = property() def attribute.fget(self): return 42 def attribute.fset(self, value): self._ignored = value
- Previous message: [Python-Dev] Declaring setters with getters
- Next message: [Python-Dev] Declaring setters with getters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list