[Python-Dev] Definining properties - a use case for class decorators? (original) (raw)
Delaney, Timothy (Tim) tdelaney at avaya.com
Mon Oct 17 04:39:15 CEST 2005
- Previous message: [Python-Dev] Early PEP draft (For Python 3000?)
- Next message: [Python-Dev] Guido v. Python, Round 1
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Ewing wrote:
class C:
foo = overridableproperty('foo', "The foo property") def getfoo(self): ... def setfoo(self, x): ... This has the advantage that the accessor methods can be overridden in subclasses with the expected effect.
This is a point I was going to bring up.
The only wart is the necessity of mentioning the property name twice, once on the lhs and once as an argument. I haven't thought of a good solution to that, yet.
Have a look at my comment to Steven Bethard's recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/408713
Tim Delaney
- Previous message: [Python-Dev] Early PEP draft (For Python 3000?)
- Next message: [Python-Dev] Guido v. Python, Round 1
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]