[Python-Dev] Extended Function syntax

Samuele Pedroni pedronis@bluewin.ch
Wed, 29 Jan 2003 20:03:34 +0100


From: "Guido van Rossum" <guido@python.org>
> > However this could work:
> >
> > class Foo(object):
> >     myprop = property:
> > """A computed property on Foo objects."""
> > def __get__(self):
> >     return ...
> > def __set__(self, value):
> >     ...
> > def __delete__(self):
> >     ...
> >
> > This would call property() with the results of parsing the indented block.
> > Not sure yet this is a good idea, but it could have many other (possibly
> > good, possibly harmful) uses.
>
> Funny, I had a vision of something very similar this morning in the
> shower. :-)
>
> The problem is that this is a *very* radical change to the grammar,
> and I'm not sure I can rigorously define how the switch from
> "expression parsing mode" to "block parsing mode" should work.

I would have thought that such a syntax is better left reserved to some
hypothetical pep for anonymous blocks (extending lambdas, not that I personally
favor/long for them) and not for something along the line of class in terms of
synthetizing an object out of a by a block populated namespace.

regards.