[Python-Dev] Merging PEP 310 and PEP 340-redux?

Guido van Rossum gvanrossum at gmail.com
Fri May 13 19:08:41 CEST 2005


[Guido van Rossum]
> > Cons:
> > - slightly less simple (__enter__ must return something for VAR;
> >   __exit__ takes optional args)

[Fredrik Lundh]
> what happened to the original "yield the target object" solution?  or did
> I just dream that?

Don't worry, that works when you use a generator. It just doesn't work
when you're using a class.

The do-statement proposal is a bit ambiguous: on the one hand it's not
strongly tied to generators, since you can easily write a class with
__enter__ and __exit__ methods; on the other hand its essential
difference from PEP 310 is that you *can* use a generator, given a
suitable decorator.

BTW, we need a name for such a decorated generator that only yields
once. I propose to call it a degenerator.

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


More information about the Python-Dev mailing list