Allowing comments after the line continuation backslash

Chris Rebert clp2 at rebertia.com
Tue Nov 2 00:42:41 CET 2010


On Mon, Nov 1, 2010 at 3:16 PM, Lawrence D'Oliveiro
<ldo at geek-central.gen.new_zealand> wrote:
> In message <4CCE6FF6.2050408 at v.loewis.de>, Martin v. Loewis wrote:
>
>> (in fact, I can't think any situation where I would use the backslash).
>
>    for \
>        Description, Attr, ColorList \
>    in \
>        (
>            ("normal", "image", MainWindow.ColorsNormalList),
>            ("highlighted", "highlight", MainWindow.ColorsHighlightedList),
>            ("selected", "select", MainWindow.ColorsSelectedList),
>        ) \
>    :
>       ...
>    #end for
>
> <http://github.com/ldo/dvd_menu_animator>

I find the level of deviation from PEP 8 in that file rather disturbing.
In any case, the backslashes are easily avoided, and readability
improved IMHO, via refactoring:

desc_attr_colors_triples = (("normal", "image", MainWindow.ColorsNormalList),
    ("highlighted", "highlight", MainWindow.ColorsHighlightedList),
    ("selected", "select", MainWindow.ColorsSelectedList))
for in description, attr, color_list in desc_attr_colors_triples:
    ...

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list