Python indentation (3 spaces)
Alan Bawden
alan at csail.mit.edu
Sun Oct 14 18:50:26 EDT 2018
Chris Angelico <rosuav at gmail.com> writes:
> On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa <marko at pacujo.net> wrote:
> > Chris Angelico <rosuav at gmail.com>:
...
> > That *could* be the situation. However, it is trumped by an older
> > convention whereby the indentation levels go as follows:
> >
> > 0:
> > 1: SPC SPC
> > 2: SPC SPC SPC SPC
> > 3: SPC SPC SPC SPC SPC SPC
> > 4: TAB
> > 5: TAB SPC SPC
> > 6: TAB SPC SPC SPC SPC
> > 7: TAB SPC SPC SPC SPC SPC SPC
> > 8: TAB TAB
>
> I've literally NEVER come across this as a convention. Not a single
> file that I have ever worked with has used it. Where is this
> convention from?
I just picked a C source code file AT RANDOM from the FreeBSD source tree
on the machine I'm using to compose this message
(/usr/src/gnu/usr.bin/man/man/glob.c), and I find that, as I expected, it
uses exactly that convention. And in that file, the comments don't line up
as the author clearly intended unless the tab stops are set every 8
columns.
In my experience this is a very common way to assume that tabs will be
interpreted. Virtually every source-code file I have encountered since the
mid 1970s (for any programming language or operating system) has assumed
either this convention or, slightly less often, its 4-column variant.
It's surprising that you've never encountered it.
--
Alan Bawden
More information about the Python-list
mailing list