Allowing comments after the line continuation backslash

Ben Finney ben+python at benfinney.id.au
Wed Nov 3 05:24:15 CET 2010


Robert Kern <robert.kern at gmail.com> writes:

> I'd go one step further:
>
>     styles = [
>         ("normal",      "image",     MainWindow.ColorsNormalList),
>         ("highlighted", "highlight", MainWindow.ColorsHighlightedList),
>         ("selected",    "select",    MainWindow.ColorsSelectedList),
>     ]
>
> Keeping the []s separate from the items and using the trailing comma
> means that I can easily add new items or reorder the items.

No problem with that, except I'd still keep the closing character
indented::

    styles = [
        ("normal",      "image",     MainWindow.ColorsNormalList),
        ("highlighted", "highlight", MainWindow.ColorsHighlightedList),
        ("selected",    "select",    MainWindow.ColorsSelectedList),
        ]

because it's consistent with how lines are grouped everywhere else in
Python: the grouping continues while the same indentation level
continues, and stops once the indentation stops.

-- 
 \      “By instructing students how to learn, unlearn, and relearn, a |
  `\         powerful new dimension can be added to education.” —Alvin |
_o__)                                    Toffler, _Future Shock_, 1970 |
Ben Finney



More information about the Python-list mailing list