Preserving program structure

Tim Hammerquist tim at vegeta.ath.cx
Thu Dec 13 22:40:09 EST 2001


David Dawkins graced us by uttering:
> So I'm using IDLE, and Alt-F5 tells me I have a problem with
> indentation.
> 
> It seems I had (inadvertently) mixed tab and space characters.
> No amount of "tabbifying" and "untabbifying" resolved the issue,
> so I had to shift *everything* to the left-margin, and re-create
> the indentation with a consistent scheme (8 space hard tabs).
> 
> While doing so, I stuffed up a lot of the program logic, because
> it wasn't always obvious which block a particular statement
> belonged in.  This dismayed me intensely.
> 
> How do experienced Python programmers avoid this problem?

I avoid it by not using IDLE. I use Vim for hardcore editing and the
Python interpreter for any ad hoc logic testing. With readline support
compiled in, the Python interp supports bash-style auto completion as
well.

In order to change tabs to spaces in-place, you can run it through a
filter like expand(1).

Tim Hammerquist
-- 
You know, we've got armadillos in our trousers.
It's really quite frightening.
    -- Nigel Tufnel, "This is Spinal Tap"



More information about the Python-list mailing list