[Python-Dev] Fun with whitespace (original) (raw)

Kurt B. Kaiser kbk at shore.net
Wed Jul 21 05:19:12 CEST 2004


"Tim Peters" <tim.one at comcast.net> writes:

Heads up! Using reindent.py to normalize whitespace in the Tools/scripts directory uncovered a file with bad syntax problems. So I repaired that file's errors, then ran reindent over the entire source tree.

I'm thinking that it might be a good idea to modify IDLE to use four-space indenting only, and remove the Tab options from the configuration dialog.

Right now, every time a program is Run/F5, IDLE runs a version of tabnanny on it and then runs a syntax check. We could add a reindent.py check after tabnanny (if tabnanny fails, the user is notified to fix things first). Indents would be normalized at 4 spaces, and if an error was detected, a dialog would warn the user that the file would be changed. The user could confirm (auto fix) or cancel and fix things manually.

I've tried to use IDLE to convert tab-indented code to space-indented, but it's never worked well for me. If you set the wrong number of spaces/tab the code gets scrambled. reindent.py seems to work fine. Are there situations in which it can fail, assuming tabnanny is happy?

The implementation would continue to create the .bak file. Alternatively, maybe the undo capability could be extended to cover the reindent. Or both.

Is it time for IDLE to enforce four-space indentation? Any opinions?

KBK



More information about the Python-Dev mailing list