indentation

Jorgen Grahn grahn+nntp at snipabacken.se
Sun Oct 19 17:08:22 EDT 2008


On Sun, 19 Oct 2008 15:50:59 -0400, Derek Martin <code at pizzashack.org> wrote:

> On Sun, Oct 19, 2008 at 06:05:08PM +0000, Jorgen Grahn wrote:
>> Doesn't pretty much everyone use spaces and a four-position indent? 
>
> I can't speak for everyone, or even "pretty much everyone"... but I
> know of several people who favor the idea of "indent with tab, align
> with space."  The advantage to this scheme is that anyone using a
> half-sane editor can very easily change the level of indentation to
> their preference, meanwhile keeping the rest of the code aligned
> properly (though this may well interfere with keeping line lengths to
> 80 columns, or some other decided-upon number). 

I'm happy to say I have never seen the kind of code you mention. If I
understand you correctly, if you sent me code to look at, I would
either have to change the TAB setting of all relevant tools to
four-spaced TABs (remembering to restore them afterwards), or suffer
looking at the code eight-indented -- twice the one I'm used to.

> I favor this myself
> actually, though I rarely use it for Python code I write, because that
> almost invariably needs to work with someone else's code who insists
> on the "standard" you mentioned.

Yes; what you do makes sense in a way, but it seems very incompatible
with what most people do.

What has made me dread alternate TAB settings is not the style you
describe, but the uncontrolled one where some lines are indented with
oddly-sized TABs and others (partly) with spaces. When trying to read
such code, it's not uncommon that you have to try several different
TAB sizes before you hit the one where the code stops looking like
gibberish. And often you don't find one, because someone beat you to
it and the code now uses several different TAB settings in different
parts of the file ... At least if it's Python code, chances are good
that it refuses to load such code, or that it crashes soon.

...
>> [0] This is an old and tedious topic ... 
>
> This is very true... though clearly to anyone who hasn't encountered
> it before, it is rather new.
>
>>     my view on TABs is that they are useless iff they aren't
>>     rendered the same way everywhere. The size 8 is hard-coded into
>>     terminals, printers and programs since ancient times; thus
>>     anything else is wrong.
>
> This, on the other hand, is quite false -- not your opinion, perhaps,
> but all of the facts you've put forth in support of it.  The tab size
> of nearly every tty device I've interacted with in the last 25 years
> *defaulted* to 8, but is configurable using any of various terminal
> control programs, such as tabs, stty, etc. (though I wouldn't know how
> to do this on Windows, or if it's even possible/relevant)...

Ok, I stand corrected. I shouldn't have brought it up, because the
defaults are what matters. Since text files contain no metainformation
about what TAB size they use, you have no chance to reconfigure your
tools for every text file they process.

/Jorgen

-- 
  // Jorgen Grahn <grahn@        Ph'nglui mglw'nafh Cthulhu
\X/     snipabacken.se>          R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list