osdir.com


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

Python indentation (3 spaces)


On 15Oct2018 00:33, Peter J. Holzer <hjp-python at hjp.at> wrote:
>On 2018-10-15 09:06:11 +1100, Chris Angelico wrote:
>> On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa <marko at pacujo.net> wrote:
>> > Chris Angelico <rosuav at gmail.com>:
>> > > Tabs for indentation have semantic meaning. Top-level has zero tabs.
>> > > One indentation level is represented by one tab. Two indentation
>> > > levels? Two tabs. It's about as perfect a representation as you could
>> > > hope for.
>> >
>> > 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
>
>That's not using tabs for indentation, that's using tabs for compressing
>spaces (somebody already mentioned that in this thread).
>
>
>> 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?
>
>It's something vi does by default, and apparently emacs as well.
>In the 1970's saving space by replacing sequences of 8 spaces
>with tabs seemed lika a good idea.
>
>There are workarounds in vi(m), but I'm not sure if you can get rid of
>that behaviour completely. I'm sure it is possible in emacs.

I'm a "just use spaces" guy. I use the tab _key_ as a shortcut to do a 
bunch of spaces.

My vim setup has this:

  set expandtab

which turns them into spaces.

Cheers,
Cameron Simpson <cs at cskk.id.au>