Allowing comments after the line continuation backslash
Ben Finney
ben+python at benfinney.id.au
Tue Nov 2 20:46:01 EDT 2010
Roy Smith <roy at panix.com> writes:
> 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
I would do the same, but fix the indentation. Making indentation depend
on the *length* of the previous line is needlessly making a maintenance
burden.
Instead, I'd 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
A single consistent level of indentation on continuation lines, no
matter what happens to the first line.
> 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.
Agreed.
> You may disagree. That's OK.
It's okay until that code gets out in the wild; then it's no longer just
a matter of one person's taste. Hence the need for conventions.
--
\ “Anyone who puts a small gloss on [a] fundamental technology, |
`\ calls it proprietary, and then tries to keep others from |
_o__) building on it, is a thief.” —Tim O'Reilly, 2000-01-25 |
Ben Finney
More information about the Python-list
mailing list