Allowing comments after the line continuation backslash

Robert Kern robert.kern at gmail.com
Tue Nov 2 23:26:10 EDT 2010


On 2010-11-02 19:46 , Ben Finney wrote:

> Instead, I'd do::
>
>      styles = [
>          ("normal",      "image",     MainWindow.ColorsNormalList),
>          ("highlighted", "highlight", MainWindow.ColorsHighlightedList),
>          ("selected",    "select",    MainWindow.ColorsSelectedList)]

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.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list