[Python-Dev] Definining properties - a use case for class decorators?

Josiah Carlson jcarlson at uci.edu
Tue Oct 18 18:55:56 CEST 2005


Aahz <aahz at pythoncraft.com> wrote:
> 
> On Mon, Oct 17, 2005, Guido van Rossum wrote:
> >
> > 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')
> 
> +1
> 
> The only other alternative is to introduce some kind of block.  This is
> a good solution that is not particularly intrusive; it leaves the door
> open to a well-designed block structure later on.  The one niggle I have
> is that it's going to be a little unwieldy to explain, but people who
> create properties really ought to understand Python well enough to deal
> with it.

I remember posing an unanswered question back when blocks were being
offered, and being that you brought up blocks again, I'll ask a more
specific variant of my original question:
    What would this mythical block statement look like that would make
properties easier to write than the above late-binding or the subclass
Property recipe?


 - Josiah



More information about the Python-Dev mailing list