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


Groups > comp.lang.python > #82014

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'programmer': 0.03; 'subject:Python': 0.06; 'interpreter.': 0.07; 'pep': 0.09; 'raises': 0.09; 'spaces': 0.09; 'python': 0.11; '"python': 0.16; 'q2.': 0.16; 'reads,': 0.16; 'sequence.': 0.16; 'tab': 0.16; 'tabs': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'looks': 0.24; '(or': 0.24; '&gt;': 0.26; 'compare': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'mix': 0.30; 'relative': 0.30; 'message-id:@mail.gmail.com': 0.30; 'lines': 0.31; 'block,': 0.31; 'indentation': 0.31; 'fri,': 0.33; 'guess': 0.33; 'equal': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'i.e.': 0.36; 'next': 0.36; 'subject:?': 0.36; 'error.': 0.37; 'so,': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'simply': 0.61; 'different': 0.65; 'situation': 0.65; 'within': 0.65; 'subject: & ': 0.68; 'krish': 0.84; 'resists': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=S7bDQqm//5MKFoKoiBYMORYAN6KmXsI8S5pGbiTZEOc=; b=fBQE6uaQNn+hU19SEfCID/Bc5YkO8hQE2ANzZey8ILifmHwYmJH9Mz4pct50Uvk6sK +uNG6mhLNad6CS3qVi/XiO5NionD46vqHSk1KPP8pYrC9Xi8aA/hv/Y9qEpQS3IXhqJ4 IR4qnJ1D2LBqUh+6PET204PJUEguAwRD8d2mroGDuYy24vn1aV1Tf7wcf4TO/ySXrPCC sCBonYHMmKppVP78gyw8/lPEZ2C1Cg1HPXShUVusXpoijyLmiXc3zIPXWsFOBeU8RAfc 0yLD/8mDU4F4YAENpEJagZZ8bQEUpXD/mUFLYxH6ODzcweJytp5BhGuRpKs+BBI670Oi tH4A==
X-Received by 10.66.248.6 with SMTP id yi6mr31577458pac.120.1417804284181; Fri, 05 Dec 2014 10:31:24 -0800 (PST)
MIME-Version 1.0
In-Reply-To <CAFaCOgyMf9rQCM1T52VAGB5RRyjEmATS2Cq3A8+KERsT8Pv0bg@mail.gmail.com>
References <CAFaCOgyMf9rQCM1T52VAGB5RRyjEmATS2Cq3A8+KERsT8Pv0bg@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 5 Dec 2014 11:30:43 -0700
Subject Re: Tabs for indentation & Spaces for alignment in Python 3?
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=047d7b15ac25b843d305097c4891
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.16635.1417804287.18130.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417804287 news.xs4all.nl 2856 [2001:888:2000:d::a6]:39154
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82014

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Fri, Dec 5, 2014 at 10:40 AM, Aahan Krish <krish@aahan.me> wrote:
> Q2. PEP 8 also reads, "Python 3 disallows mixing the use of tabs and
spaces for indentation."
>
> So, if I am using tabs for indentation and spaces for alignment, is it
still considered "mixing the use of tabs and spaces" in Python 3? (Please
see this example.)

No, you can mix tabs and spaces as long as you do so consistently within a
block, i.e. if one line is indented with <tab><sp><sp><tab> then the next
line in the same block had better start with that same exact sequence. The
difference is that Python 2 when trying to compare indentation will treat a
tab as equal to 8 spaces (or was it 4?) which can lead to situations where
the relative indentation of two lines looks one way to the programmer but
is lexed a different way by the interpreter. Python 3 resists the
temptation to guess in this situation and simply raises an error.

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


Thread

Re: Tabs for indentation & Spaces for alignment in Python 3? Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-05 11:30 -0700

csiph-web