[Python-Dev] PEP 343 - next steps

Russell E. Owen rowen at cesmail.net
Sat Jun 11 01:11:34 CEST 2005


In article <ca471dc2050610132375ca7c70 at mail.gmail.com>,
 Guido van Rossum <gvanrossum at gmail.com> wrote:

>...
> - 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 agree that (a) sounds better.

Also, I think it is very reasonable to require that multiple variables 
be in parenthesis. You can always lift the restriction later (i.e. if 
enough folks complain and you decide never to implement (a)), but you 
can't add such a restriction later.

One nit-pick: I suggest not using the term "list of <anything> in 
parenthesis" in the PEP or other docs. It's clear here but may add to 
some people's list vs tuple confusion.

-- Russell



More information about the Python-Dev mailing list