osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python indentation (3 spaces)


Chris Angelico <rosuav at gmail.com>:
> I'm saying I have never seen is this:
>
> On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa <marko at pacujo.net> wrote:
>> 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
>
> Specifically that two-space indents and tab-collapsing are a
> *convention*. I have never seen this used anywhere, much less seen it
> commonly enough to call it a convention.

The two-space indentation is the out-of-the-box default for emacs.
However, the tab collapsing principle is a universal default. If you go
against it, you will have to educate more tools than your editor. For
example, try running this Python snippet (in REPL or as a program):

    for i in range(32):
        print("x{}\ty".format(" " * i))


Marko