Arcane question regarding white space, editors, and code collapsing

Ben Finney ben+python at benfinney.id.au
Wed Nov 18 20:27:41 EST 2009


Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> writes:

> On Thu, 19 Nov 2009 10:56:35 +1100, Ben Finney wrote:
>
> > It's quite improper (though syntactically null, in Python) to have
> > trailing whitespace on lines. That includes blank lines.
>
> Blank lines are far from improper in Python, they're recommended by
> PEP 8.

I phrased that poorly. I meant “That [admonishment against trailing
whitespace] includes trailing whitespace on otherwise-empty lines”.

> > One major reason is that trailing whitespace causes spurious
> > invisible differences between otherwise-identical lines when doing
> > an automatic comparison, which is done quite a lot in collaboration
> > and version control.
>
> Then you need better comparison software that doesn't give so many
> false matches due to insignificant differences.

I have such tools, but I shouldn't require others to also have and use
them. It would be irresponsible of me to spew output that causes
breakage in the absence of such tools.

My position on this is: be strict in what you emit (i.e. no trailing
whitespace), and construct your output to function well with
lowest-common-denominator standard tools (i.e. don't expect
sophistication above the standard ‘diff -u’ etc.).

-- 
 \      “It's up to the masses to distribute [music] however they want |
  `\    … The laws don't matter at that point. People sharing music in |
_o__)        their bedrooms is the new radio.” —Neil Young, 2008-05-06 |
Ben Finney



More information about the Python-list mailing list