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?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'url:pypi': 0.03; 'subject:Python': 0.06; '(except': 0.07; 'spaces': 0.09; 'python': 0.11; 'c++.': 0.16; 'frees': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'indent': 0.16; 'mode,': 0.16; 'pep8': 0.16; 'tab': 0.16; 'tabs': 0.16; 'wrote:': 0.18; 'fit': 0.20; 'code,': 0.22; 'header:User-Agent:1': 0.23; 'people,': 0.24; 'looks': 0.24; '(or': 0.24; 'source': 0.25; 'equivalent': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; '[1]': 0.29; 'am,': 0.29; 'points': 0.29; 'characters': 0.30; 'skip:( 20': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'linux': 0.33; 'url:python': 0.33; 'running': 0.33; 'programmers': 0.33; 'style': 0.33; 'could': 0.34; 'editor': 0.35; 'but': 0.35; 'c++': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'message-id:@gmail.com': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'space': 0.40; 'course.': 0.60; 'most': 0.60; 'course': 0.61; 'subject: & ': 0.68; 'dilemma': 0.84; 'drama': 0.84
X-Virus-Scanned amavisd-new at torriefamily.org
Date Sat, 06 Dec 2014 09:41:57 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11
MIME-Version 1.0
To python-list@python.org
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>
In-Reply-To <87mw71maqu.fsf@elektro.pacujo.net>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16653.1417884132.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417884132 news.xs4all.nl 2965 [2001:888:2000:d::a6]:36053
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82039

Show key headers only | 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