Allowing comments after the line continuation backslash

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Wed Nov 3 08:50:40 CET 2010


In message <roy-A0F407.20170602112010 at news.panix.com>, Roy Smith wrote:

> In article <iaq5ro$vpc$4 at lust.ihug.co.nz>,
>  Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> wrote:
> 
>> In message <roy-A96D07.07462302112010 at news.panix.com>, Roy Smith wrote:
>> 
>> > In this case, I think I would do:
>> > 
>> > styles = [("normal",      "image",     MainWindow.ColorsNormalList),
>> >           ("highlighted", "highlight",
>> >           MainWindow.ColorsHighlightedList),
>> >           ("selected",    "select",    MainWindow.ColorsSelectedList)]
>> > 
>> > for in description, attr, color_list in styles:
>> >    blah, blah, blah
>> 
>> And so you have managed to separate one set of looping conditions into
>> two parts. What is the significance of the name “styles”? None at all.
>> What purpose does it serve? None, really. Does it ease the maintenance
>> burden? No, but by splitting your attention across two places, it
>> actually adds to it.
> 
> I suppose readability is in the eye of the reader, but, yes, I agree
> that I have split this into two parts.  The parts are
> 
> 1) The table of data
> 
> 2) The looping construct

But the table of data makes no sense outside of the looping construct. That 
table does nothing other than define the bounds of the loop. Without the 
loop, it has no reason to exist. It makes no more sense than

    styles = range(0, 100)
    for i in styles :
        ...

> Where we seem to disagree is whether that makes things more or less
> readable :-)  To me, it makes is more readable because it lets me
> understand one chunk, then move on to understanding the next chunk.

Which means you don’t understand the purpose of the code at all. Go look at 
it in its entirety, and you’ll see what I mean.

<http://github.com/ldo/dvd_menu_animator>



More information about the Python-list mailing list