[Python-ideas] allow line break at operators

Terry Reedy tjreedy at udel.edu
Sat Sep 3 15:01:31 EDT 2011


On 9/3/2011 3:51 AM, Yingjie Lan wrote:
> I agree that long lines of code are not very common in many projects,
> though it might be the case with some heavily involved in math. For some
> reason, when the feature of free line breaking came about in computer
> languages, it is welcomed and generally well accepted.

Every language with blocks needs some mechanism to indicate the 
beginning and ending of blocks and of statements within blocks. If 
visible fences ('begin/end' or '{}') and statement terminators (';') are 
used, then '\n' can be treated as merely a space, as it is in C, for 
instance.

> Python uses indentation for blocks,

and it uses unescaped '\n' (with two escapement options) to terminate 
statements. This is fundamental to Python's design and goes along with 
significant indents.

 > and by the same mechanism, line breaking can be
> accommodated without requiring parenthesis or ending backslashes.

You need proof for your claim that indentation can be used for both jobs 
in the form of a grammar that works with Python's parser. I am dubious 
that you can do that with an indents *after* the newline.

Even if you could, it would be confusing for human readers. There would 
then be three ways to escape newline, with one doing double duty. And 
for what? Merely to avoid using either of the two methods already available.

-- 
Terry Jan Reedy




More information about the Python-list mailing list