[Python-Dev] PEP 343 - next steps

Brett C. bac at OCF.Berkeley.EDU
Sat Jun 11 07:02:20 CEST 2005


Guido van Rossum wrote:
[SNIP - Guido already said throw() is the name to be used]
> - Whether and how to keep a door open for a future extension to the
> syntax that allows multiple resources to be acquired in a single
> with-statement. Possible syntax could be
> 
> (a)    with EXPR1 [as VAR1], EXPR2 [as VAR2], EXPR3 [as VAR3], ...:
> 
> or
> 
> (b)    with EXPR1, EXPR2, EXPR3, ... as VAR1, VAR2, VAR3, ...:
> 
> Variant (a) seems better and is more analogous to the use of 'as' in
> import statements, and (b) has the disadvantage that if you want to
> acquire several resources and not all of them have an associated
> variable, you'll have to sprinkle dummy variables on the right of
> 'as'. So (a) would have my preference. But I would still like to start
> off without this extension. The issue is: if we allow VAR to be a
> comma-separated list of variables now, that cuts off the extension to
> (a) in the future; so the PEP would have to be amended to state that
> VAR must be a single variable or a list of variables IN PARENTHESES.
> Thoughts?
> 

I like a), so I say restrict the grammar as needed to allow it become a
possibility.  Forcing parens is a minor thing and since this is not
syntactically the same as assignment the difference is negligible.

-Brett


More information about the Python-Dev mailing list