[Python-ideas] Allow parentheses to be used with "with" block
MRAB
python at mrabarnett.plus.com
Mon Feb 16 00:37:34 CET 2015
On 2015-02-15 21:52, Neil Girdhar wrote:
> It's great that multiple context managers can be sent to "with":
>
> with a as b, c as d, e as f:
> suite
>
> If the context mangers have a lot of text it's very hard to comply with
> PEP8 without resorting to "\" continuations, which are proscribed by the
> Google style guide.
>
> Other statements like import and if support enclosing their arguments in
> parentheses to force aligned continuations. Can we have the same for
> "with"?
>
> E.g.
>
> with (a as b,
> c as d,
> e as f):
> suite
>
> This is a pretty minor change to the grammar and parser.
>
It's not as minor as you think, because the part before the 'as' is an
expression, and expressions can start with a parenthesis.
For example, how do you distinguish between:
with (as a b):
and:
with (a) as b:
More information about the Python-ideas
mailing list