Allow multiline conditions and the like

Ben Finney ben+python at benfinney.id.au
Mon Nov 1 03:13:13 EDT 2010


Yingjie Lan <lanyjie at yahoo.com> writes:

> Allow the conditions in the if-, elif-, while-, for-, and with-clauses
> to span multiple lines without using a backlalsh at the end of a line,

You can already do this with any expression: use parentheses.


Yingjie Lan <lanyjie at yahoo.com> writes:

> I would like to have comments after the line continuation backslash.

I have almost never needed a line continuation backslash; I consider
them a code smell.

> >>> if a > 0 \ #comments for this condition
>       and b > 0:
>     #do something here

    if (a > 0  # Comments for this condition
        and b > 0):
        # Do something here

-- 
 \         “Alternative explanations are always welcome in science, if |
  `\   they are better and explain more. Alternative explanations that |
_o__) explain nothing are not welcome.” —Victor J. Stenger, 2001-11-05 |
Ben Finney



More information about the Python-list mailing list