Restrict 'as VAR' to VAR being a single variable or a parenthesized
series of variables. This keeps the door open for a future extension with multiple as-clauses.
This commit is contained in:
parent
d75a3b0145
commit
a61abd2828
10
pep-0343.txt
10
pep-0343.txt
|
@ -207,8 +207,12 @@ Specification: The 'with' Statement
|
|||
BLOCK
|
||||
|
||||
Here, 'with' and 'as' are new keywords; EXPR is an arbitrary
|
||||
expression (but not an expression-list) and VAR is an arbitrary
|
||||
assignment target (which may be a comma-separated list).
|
||||
expression (but not an expression-list) and VAR is a single
|
||||
assignment target. It can *not* be a comma-separated sequence of
|
||||
variables, but it *can* be a *parenthesized* comma-separated
|
||||
sequence of variables. (This restriction makes a future extension
|
||||
possible of the syntax to have multiple comma-separated resources,
|
||||
each with its own optional as-clause.)
|
||||
|
||||
The "as VAR" part is optional.
|
||||
|
||||
|
@ -573,7 +577,7 @@ Examples
|
|||
|
||||
Used as follows:
|
||||
|
||||
with opening_w_error("/etc/passwd", "a") as f, err:
|
||||
with opening_w_error("/etc/passwd", "a") as (f, err):
|
||||
if err:
|
||||
print "IOError:", err
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue