[Python-Dev] Merging PEP 310 and PEP 340-redux?
Fredrik Lundh
fredrik at pythonware.com
Fri May 13 18:47:45 CEST 2005
Guido van Rossum wrote:
> PEP 340 redux
> =============
>
> Syntax:
> do EXPR [as VAR]:
> BLOCK
>
> Translation:
> abc = EXPR
> [VAR =] abc.__enter__()
> try:
> BLOCK
> finally:
> abc.__exit__(*"sys.exc_info()") # Not exactly
>
> Pros:
> - can use a decorated generator as EXPR
> - separation of EXPR and VAR (VAR gets what EXPR.__enter__() returns)
>
> Cons:
> - slightly less simple (__enter__ must return something for VAR;
> __exit__ takes optional args)
what happened to the original "yield the target object" solution? or did
I just dream that?
</F>
More information about the Python-Dev
mailing list