[Python-Dev] Multiline with statement line continuation
Georg Brandl
g.brandl at gmx.net
Tue Aug 12 20:52:44 CEST 2014
On 08/12/2014 06:57 PM, Armin Rigo wrote:
> Hi,
>
> On 12 August 2014 01:08, Allen Li <cyberdupo56 at gmail.com> wrote:
>> with (open('foo') as foo,
>> open('bar') as bar,
>> open('baz') as baz,
>> open('spam') as spam,
>> open('eggs') as eggs):
>> pass
>
> +1. It's exactly the same grammar extension as for "from import"
> statements, for the same reason.
Not the same: in import statements it unambiguously replaces a list
of (optionally as-renamed) identifiers. Here, it would replace an
arbitrary expression, which I think would mean that we couldn't
differentiate between e.g.
with (expr).meth(): # a line break in "expr"
# would make the parens useful
and
with (expr1, expr2):
cheers,
Georg
More information about the Python-Dev
mailing list