[Python-ideas] 80 character line width vs. something wider

Ben Finney ben+python at benfinney.id.au
Wed May 20 14:59:57 CEST 2009


spir <denis.spir at free.fr> writes:

> Ben Finney s'exprima ainsi:
> > Simply break at the opening container character, and indent a single
> > level to make all the contents line up::
> > 
> >     try:
> >         my_final_result = finalResultComputer(
> >             arg1_from_abunch_of_args,
> >             args_should_align_properly,
> >             [so, what, if, they, re, compound])
> >     except AttributeError, error:
> >         raise computeError(
> >             "foo .........         bar"
> >             "<--All message text lines should start here."
> >             % (String, interpolation, argument, list, as, well))
> 
> Yes, I partially agree with you indentation mode. But to my eyes
> (maybe it's only me) the result (1) seems to suggest ordinary python
> indentation, which it is not

I beg to differ. Python indentation is inspired by the indentation that
programmers do *anyway* to make the structure of their programs clearer.
Some of it is syntactically significant, but that doesn't make the
practice of indentation any less meaningful where it's not syntax.

The indentation, in this case, is indicating that the indented lines are
subordinate to the lines at an outer level of indentation.

> and (2) does not make obvious what continuation lines belong to.

I think it's obvious that the continuation lines “belong to” the
statement that begins on an outer level of indentation. This is, indeed,
the entire point of indenting those continuation lines beneath the line
which begins the statement, no?

> This can be a bit improved (again, to my eyes) using
> ~ double indentation for continuation lines
> ~ closing sings (parens, etc) on their own line

I have no objection to either of those, except for a slight waste of
space for no benefit that I can appreciate. Certainly not egregious like
the original example.

-- 
 \       “Yesterday I told a chicken to cross the road. It said, ‘What |
  `\                                             for?’” —Steven Wright |
_o__)                                                                  |
Ben Finney




More information about the Python-ideas mailing list