Allen Li <cyberdup...@gmail.com> writes:

> Currently, this works with explicit line continuation, but as all
> style guides favor implicit line continuation over explicit, it would
> be nice if you could do the following:
>
>     with (open('foo') as foo,
>           open('bar') as bar,
>           open('baz') as baz,
>           open('spam') as spam,
>           open('eggs') as eggs):
>         pass
>
> Currently, this is a syntax error

Even if it weren't a syntax error, the syntax would be ambiguous. How
will you discern the meaning of::

    with (
            foo,
            bar,
            baz):
        pass

Is that three separate context managers? Or is it one tuple with three
items?

I am definitely sympathetic to the desire for a good solution to
multi-line ‘with’ statements, but I also don't want to see a special
case to make it even more difficult to understand when a tuple literal
is being specified in code. I admit I don't have a good answer to
satisfy both those simultaneously.

-- 
 \           “We have met the enemy and he is us.” —Walt Kelly, _Pogo_ |
  `\                                                        1971-04-22 |
_o__)                                                                  |
Ben Finney

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to