Tab wars revisited (was Re: Python indentation)
Peter Hansen
peter at engcorp.com
Wed Jul 7 16:14:20 EDT 2004
Istvan Albert wrote:
> What will bother you even more is that the "official"
> recommendation is that you should be using spaces to
> indent not tabs... the reason appears to be that tabs
> might not copy properly from some terminal windows...
Actually, that's only one of several reasons. Another is
that there is no universally agreed-upon definition of how
much indentation is intended for the ASCII TAB character,
which leads to several problems including ambiguity when
spaces and tabs are mixed.
Ambiguity sucks but a SPACE is a SPACE is a SPACE.
> I like python very much, but every time I see a space indented
> module the first thing I do is to replace the spaces with
> tabs.
I had an urge to do that really early on, from some leftover
feeling that I was wasting hard drive space. My advice is
to get over it. You'll sleep better, not worrying about all
the SPACE-infested code out there in the world that you
haven't had a chance to "fix". :-)
> But if you stick with the "official" recommendation
> then you have to press four spaces or four deletes on the first level,
> eight on the second etc... to align stuff...
I can't imagine anyone actually thinks this is what they really
are expected to do. If your editor is really broken, use single
spaces in the interim, while you find a non-broken one.
> Yeah, yeah I know that this or that editor has a shortcut enabled via
> CTRL+ALT+INSERT+SPACE+double-click+W and that will do the job in one
> keystroke,
*Any* decent editor can be configured to inject spaces up to the
next defined tab-stop when TAB is hit. By definition, therefore,
any editor that cannot is broken.
-Peter
More information about the Python-list
mailing list