allow line break at operators
Yingjie Lan
lanyjie at yahoo.com
Wed Aug 10 08:58:24 EDT 2011
> On Wed, Aug 10, 2011 at 10:56 AM, Dan Sommers <dan at tombstonezero.net>
> wrote:
>> In terms of easier to read, I find code easier to read when the
>> operators are at the beginnings of the lines (PEP 8 notwithstanding):
>>
>> x = (someobject.somemethod(object3, thing)
>> + longfunctionname(object2)
>> + otherfunction(value1, value2, value3))
>>
>
> Without the parentheses, this is legal but (probably) useless; it
> applies the unary + operator to the return value of those functions.
:No, in some other languages it might be legal, but this is Python.
:without the parentheses it is a syntax error.
This discussion leads me to this question:
Is it possible for python to allow free splitting of single-line statements
without the backslashes, if we impose that expressions can only be split
when it is not yet a finished expression? Note: splitting before closing
parenthis, brace, or bracket can be viewed as special case of this
more general rule.
Yingjie
More information about the Python-list
mailing list