[Python-Dev] Proposed changes to PEP 343

Eric Nieuwland eric.nieuwland at xs4all.nl
Fri Oct 7 15:38:20 CEST 2005


Nick Coghlan wrote:

> 1. Amend the statement specification such that:
>
>        with EXPR as VAR:
>            BLOCK
>
> is translated as:
>
>        abc = (EXPR).__with__()
>        exc = (None, None, None)
>        VAR = abc.__enter__()
>        try:
>            try:
>                BLOCK
>            except:
>                exc = sys.exc_info()
>                raise
>        finally:
>            abc.__exit__(*exc)

Is this correct?
What happens to

	with 40*13+2 as X:
		print X

?

--eric



More information about the Python-Dev mailing list