[Python-ideas] Parenthesized Compound With Statement

Nick Coghlan ncoghlan at gmail.com
Wed Jul 3 10:19:44 CEST 2013


On 3 July 2013 15:29, Matthew Lefavor <mclefavor at gmail.com> wrote:

> Works for me; I'll rescind my suggestion.
>
> The following is not intended as an objection, but rather as an
> opportunity for me to be educated about Python design decisions: Why were
> parenthetical import statements added? Is it simply because import
> statements are more common?
>

Different times, and no syntactical ambiguity. with statements and asserts
are different, as they already support parens (they just mean something
different, and even though that meaning isn't useful, it's still valid
syntax).

For with statements, long ones can either be broken up with backslashes, or
(in 3.3+) modified to use contextlib.ExitStack.

Assert statements and escaping the first newline when dedenting an indented
multi-line string literal are the other two main use cases where the
escaped newline is the preferred (or only) option.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130703/b83ab1c2/attachment.html>


More information about the Python-ideas mailing list