[Python-3000] PEP 30XZ: Simplified Parsing

Giovanni Bajo rasky at develer.com
Mon Apr 30 14:32:22 CEST 2007

(-CC python-dev)

On 30/04/2007 5.29, Jim Jewett wrote:

> Rationale for Removing Explicit Line Continuation
>     A terminal "\" indicates that the logical line is continued on the
>     following physical line (after whitespace).
>     Note that a non-terminal "\" does not have this meaning, even if the
>     only additional characters are invisible whitespace.  (Python depends
>     heavily on *visible* whitespace at the beginning of a line; it does
>     not otherwise depend on *invisible* terminal whitespace.)  Adding
>     whitespace after a "\" will typically cause a syntax error rather
>     than a silent bug, but it still isn't desirable.
>     The reason to keep "\" is that occasionally code looks better with
>     a "\" than with a () pair.
>         assert True, (
>             "This Paren is goofy")
>     But realistically, that paren is no worse than a "\".  The only
>     advantage of "\" is that it is slightly more familiar to users of
>     C-based languages.  These same languages all also support line
>     continuation with (), so reading code will not be a problem, and
>     there will be one less rule to learn for people entirely new to
>     programming.

I was in favor of one of the alternatives that were proposed here: line 
continuation through indentation:

    a = 123 *
        (12 + 4) / 8

    assert True,
         "No goofy paren" +
         ", dude"

... and don't tell me that you need a character there because using just 
indentation is hard to read :)

Even if you don't want to champion this solution in your PEP, you should at 
least list it among the alternatives.
Giovanni Bajo
Develer S.r.l.

More information about the Python-3000 mailing list