[Python-Dev] Extended Function syntax

Guido van Rossum guido@python.org
Sat, 01 Feb 2003 13:29:12 -0500


> On Thu, Jan 30, 2003 at 09:02:23PM -0500, Guido van Rossum wrote:
> >   v = e:
> >      S
> > 
> > would be equivalent to
> > 
> >   v = e(T)

[Armin]
> Just to throw more oil on the fire, note that this looks quite a lot like
> 
>     for v in e:
>         S

Huh?  Not to my eyes.  Unless you basically ignore all keywords, in
which case there's no difference between an if and a while block
either.  That doesn't seem to be a useful POV.

> For example, it is quite messy but you can already define
> 'newproperty' to let you do the following in 2.2:
> 
>     class X:
>        for count in newproperty:
>           def get(self):
>              return self._count
>           def set(self, value):
>              self._count = value

Messy is the word.  I don't think this existence proof will convince
anyone that we don't need a new feature then.

> Similarily you can "almost" already write the following for locks:
> 
>     for _ in acquired(lock):
>         ...
> 
> i.e. you can define acquired() so that the loop is done exactly
> once, and the lock released at the end.  It doesn't really work
> because you there is no place in acquired() you can put the
> try:...finally:.
> 
> Just-drawing-parallels'ly yours,

I'm confused.  You & Samuele both sometimes have a rhetorical style
that leaves me with no idea of the point you're trying to make.

Please say it outright.

--Guido van Rossum (home page: http://www.python.org/~guido/)