[Python-Dev] Definining properties - a use case for class decorators? (original) (raw)
Barry Warsaw barry at python.org
Tue Oct 18 04:08:48 CEST 2005
- Previous message: [Python-Dev] Definining properties - a use case for class decorators?
- Next message: [Python-Dev] Definining properties - a use case for class decorators?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, 2005-10-17 at 21:55, Guido van Rossum wrote:
Let's change the property built-in so that its arguments can be either functions or strings (or None). If they are functions or None, it behaves exactly like it always has.
If an argument is a string, it should be a method name, and the method is looked up by that name each time the property is used. Because this is late binding, it can be put before the method definitions, and a subclass can override the methods. Example: class C: foo = property('getFoo', 'setFoo', None, 'the foo property') def getFoo(self): return self.foo def setFoo(self, foo): self.foo = foo What do you think?
Ick, for all the reasons that strings are less appealing than names. IMO, there's not enough advantage in having the property() call before the functions than after.
-Barry
-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-dev/attachments/20051017/a14d6183/attachment-0001.pgp
- Previous message: [Python-Dev] Definining properties - a use case for class decorators?
- Next message: [Python-Dev] Definining properties - a use case for class decorators?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]