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


Groups > comp.lang.python > #82021

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

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'essentially': 0.04; 'configure': 0.05; 'insert': 0.05; 'root': 0.05; 'subject:Python': 0.06; 'convention.': 0.07; 'practice,': 0.07; 'we,': 0.07; 'differing': 0.09; 'formatting': 0.09; 'latter': 0.09; "people's": 0.09; 'pep': 0.09; 'screen.': 0.09; 'spaces': 0.09; 'width': 0.09; 'python': 0.11; 'better?': 0.16; 'decision,': 0.16; 'editor,': 0.16; 'fit,': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'hint': 0.16; 'ideally,': 0.16; 'indent': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'play.': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'tab': 0.16; 'tabs': 0.16; 'whatsoever': 0.16; 'wrote:': 0.18; 'pieces': 0.19; 'programming': 0.22; 'preferred': 0.22; 'header:User- Agent:1': 0.23; 'align': 0.24; 'cheers,': 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'feature': 0.29; 'thus': 0.29; 'mix': 0.30; 'specified': 0.30; "i'm": 0.30; 'code': 0.31; 'convenience': 0.31; 'multiline': 0.31; 'own,': 0.31; "user's": 0.31; 'covered': 0.32; 'another': 0.32; '(i.e.': 0.33; 'development.': 0.33; 'entirely': 0.33; 'core': 0.34; 'common': 0.35; '(2)': 0.35; 'editor': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'received:com.au': 0.36; 'scheme': 0.36; 'vice': 0.36; "didn't": 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'should': 0.36; 'too': 0.37; 'two': 0.37; 'system,': 0.38; 'configured': 0.38; 'displays': 0.38; 'initially': 0.38; 'received:211': 0.38; 'same.': 0.38; 'whatever': 0.38; 'to:addr :python-list': 0.38; 'files': 0.38; 'itself': 0.39; 'visual': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'users': 0.40; 'according': 0.40; 'how': 0.40; 'read': 0.60; 'most': 0.60; 'affect': 0.61; 'content-disposition:inline': 0.62; 'such': 0.63; 'choose': 0.64; 'different': 0.65; 'six': 0.68; 'approaches': 0.68; 'debate': 0.68; 'rendering': 0.68; 'subject: & ': 0.68; 'caused': 0.69; 'krish': 0.84; 'feet': 0.93; 'mr.': 0.98
Date Sat, 6 Dec 2014 07:37:58 +1100
From Cameron Simpson <cs@zip.com.au>
To python-list@python.org
Subject Re: Tabs for indentation & Spaces for alignment in Python 3?
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <CAFaCOgyMf9rQCM1T52VAGB5RRyjEmATS2Cq3A8+KERsT8Pv0bg@mail.gmail.com>
User-Agent Mutt/1.5.23 (2014-03-12)
References <CAFaCOgyMf9rQCM1T52VAGB5RRyjEmATS2Cq3A8+KERsT8Pv0bg@mail.gmail.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=BdjhjNd2 c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=J0QyKEt1u0cA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=A92cGCtB03wA:10 a=jb_FreNZVqp94r6ZUBgA:9 a=Ij9yAzLX9gJfv3IS:21 a=O_WwPLsSgcwxzp7E:21 a=CjuIK1q_8ugA:10
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.16639.1417811883.18130.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417811883 news.xs4all.nl 2954 [2001:888:2000:d::a6]:47559
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82021

Show key headers only | View raw


On 05Dec2014 17:40, Aahan Krish <krish@aahan.me> wrote:
>*Q1.* This is not to debate the decision, but I really wanted to know the
>reason why PEP 8 chose to go with spaces instead of tabs. I read that tabs
>were initially preferred over spaces (esp. Mr. Rossum)? What caused the
>decision that spaces are better?

Essentially because the space is always the same.

>According to Core Python Programming (Book):
>...because tabs vary in the number of spaces depending on your system, we
>> recommend not using tabs if there is any hint of cross-platform development.
>
>Isn't that a feature of tabs? (i.e. allowing the user to configure the size
>of a tab stop in his editor, which has no affect whatsoever on the tab
>character itself or how it displays in another user's editor.)

Yes, but in practice it causes varying degrees of pain.

Ideally, the various pieces of code have differing indents and that would be 
specified entirely with tabs. In practice, (1) people mix them and (2) people 
make other formatting decisions based on the rendering width of tabs in 
whatever editor they're using at the time, particularly with multiline strings 
such as docstrings.

There are two common approaches to TABs: the purists who uses TABs entirely so 
that other users can align the code as they see fit, and the pragmatists who 
configure their editors to accept the TAB _keystroke_ and have it insert spaces 
according to their tab convention.

I'm in the latter category; I have spent too much time reading files indented 
with TABs by people using a different tabwidth to my own, and thus looking 
aweful on my screen. The original author didn't choose to make it awful, but 
their tabs rendered in my tab scheme look awful. And doubtless vice versa. The 
root cause of this is that when we, as humans, indent with tabs, we do it to 
achieve a certain visual effect; as though a certain number of spaces were in 
play.

So my editor is configured to accept the tab key for convenience of typing, but 
to insert spaces.

Cheers,
Cameron Simpson <cs@zip.com.au>

In My Egotistical Opinion, most people's C programs should be indented six
feet downward and covered with dirt.    - Blair P. Houghton

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


Thread

Re: Tabs for indentation & Spaces for alignment in Python 3? Cameron Simpson <cs@zip.com.au> - 2014-12-06 07:37 +1100
  Re: Tabs for indentation & Spaces for alignment in Python 3? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-06 09:29 +1100
    Re: Tabs for indentation & Spaces for alignment in Python 3? Cameron Simpson <cs@zip.com.au> - 2014-12-06 10:47 +1100

csiph-web