Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82039

Re: Tabs for indentation & Spaces for alignment in Python 3?

Date 2014-12-06 09:41 -0700
From Michael Torrie <torriem@gmail.com>
Subject Re: Tabs for indentation & Spaces for alignment in Python 3?
References <CAFaCOgzqxcvuKBrcSkK+DRm-5pHuh6QCXi1PKG4LHGqdBjLF_A@mail.gmail.com> <m5tpqg$iqi$1@ger.gmane.org> <mailman.16650.1417835105.18130.python-list@python.org> <87mw71maqu.fsf@elektro.pacujo.net>
Newsgroups comp.lang.python
Message-ID <mailman.16653.1417884132.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 12/06/2014 01:40 AM, Marko Rauhamaa wrote:
> Michael Torrie <torriem@gmail.com>:
> 
>> In fact a decent editor that is auto-indenting code would, at least in
>> C or C++ mode, do that automatically.
> 
> A decent editor frees you from this dilemma entirely:
> 
>     (custom-set-variables
>      '(indent-tabs-mode nil))

What dilemma?  Do you mean you can avoid the drama of tabs by going all
spaces?  Of course in Python this is the recommended course.

But that's typically not what I, or most people, use in C or C++.  And
one of the OP's points is that by using tabs for indent, and spaces for
alignment, you can have the best of both worlds.  Programmers can set
their tab size to anything they want, and it still looks good (except of
Linux kernel source code, which only will ever look right at tabs
equivalent to 8 spaces).  He wanted to know if he could still do that in
Python3, and the answer is "yes" although we recommend highly just
sticking to pep8 4 space characters per indent and no tabs whatsoever.

Of course any validly-formatted Python code (or C code) can be made to
look right and work right by running autopep8[1] on it.  Just like
"indent" can make your C code fit whatever style guide you need.

[1] https://pypi.python.org/pypi/autopep8/

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Tabs for indentation & Spaces for alignment in Python 3? Michael Torrie <torriem@gmail.com> - 2014-12-05 20:04 -0700
  Re: Tabs for indentation & Spaces for alignment in Python 3? Marko Rauhamaa <marko@pacujo.net> - 2014-12-06 10:40 +0200
    Re: Tabs for indentation & Spaces for alignment in Python 3? Michael Torrie <torriem@gmail.com> - 2014-12-06 09:41 -0700
      Re: Tabs for indentation & Spaces for alignment in Python 3? Marko Rauhamaa <marko@pacujo.net> - 2014-12-06 18:57 +0200
        Re: Tabs for indentation & Spaces for alignment in Python 3? Michael Torrie <torriem@gmail.com> - 2014-12-06 10:26 -0700
          Re: Tabs for indentation & Spaces for alignment in Python 3? Marko Rauhamaa <marko@pacujo.net> - 2014-12-06 22:04 +0200
    Re: Tabs for indentation & Spaces for alignment in Python 3? Chris Angelico <rosuav@gmail.com> - 2014-12-07 03:46 +1100

csiph-web