[Python-Dev] Whitesapce normalization

Tim Peters tim.one@home.com
Mon, 15 Jan 2001 23:43:06 -0500


You may have noticed that I checked in changes to most of the modules in the
top level of Lib yesterday (Sunday).  This is part of a Crusade that was
supposed to happen before 2.0a1, but got dropped on the floor then due to
misunderstandings:  make the Python code we distribute adhere to Guido's
style guide (4-space indents, no hard tabs), + clean up minor whitespace
nits (no stray blank lines at the ends of files, no trailing whitespace on
lines, last line of the file should end with a newline).

It would be nice if people cleaned up their code this way too; I'm not going
to go thru the entire distribution doing this.  So, if you give a rip, pick
a directory or some modules you're fond of, and clean 'em up.

The program Tools/scripts/reindent.py does all of the above for you, so it's
not hard.  But it takes some care in two areas, which is why I did the top
level of Lib one file at a time by hand, and studied diffs by eyeball before
checking in any changes:

+ It's unlikely but possible that some program file *depends* on trailing
whitespace.  That plain sucks (it's *going* to break sooner or later), but
reindent.py can't help you there.

+ While reindent should never otherwise damage program logic, very strange
commenting or docstring styles may get mangled by it, making code and/or
docs hard to read.  reindent works very hard to do a good job on that, and
indeed I found no need to make manual changes to anything it did in the top
level of Lib.  But check anyway.  Especially some of the very oldest modules
are littered with ugly stuff like

    #

all over the place, from back when nobody had an editor smart enough to skip
over preceding blank lines when suggesting indentation for the current line.
Then again, maybe we should just drop the Irix5 directory <wink>.

voice-in-the-wilderness-ly y'rs  - tim