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


Groups > comp.lang.python > #34032

Re: Re: re.search when used within an if/else fails

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <driscoll@cs.wisc.edu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'warnings': 0.03; 'interpreter': 0.04; 'say,': 0.05; 'option,': 0.07; 'python': 0.09; 'pep': 0.09; 'tab': 0.09; 'cc:addr:python-list': 0.10; 'thread': 0.11; ':-)': 0.13; '"code': 0.16; '-tt': 0.16; 'differs': 0.16; 'filename:fname piece:signature': 0.16; 'indent': 0.16; 'invoking': 0.16; 'mixture': 0.16; 'subject:fails': 0.16; 'subject:when': 0.16; 'tabs': 0.16; 'wrote:': 0.17; 'projects,': 0.17; '(in': 0.18; 'do.': 0.21; 'error.': 0.21; 'converted': 0.22; 'default,': 0.22; 'cc:2**0': 0.23; 'second': 0.24; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'errors.': 0.27; 'mix': 0.27; 'strongly': 0.27; 'options': 0.27; 'subject:/': 0.28; 'complain': 0.29; 'context,': 0.29; 'editors': 0.29; 'quoting': 0.29; 'spaces': 0.29; 'probably': 0.29; "i'm": 0.29; 'code': 0.31; 'could': 0.32; 'strict': 0.33; 'recommended': 0.33; 'another': 0.33; "can't": 0.34; 'third': 0.34; 'pm,': 0.35; 'really': 0.36; 'subject:': 0.36; 'but': 0.36; 'test': 0.36; 'should': 0.36; 'bad': 0.37; 'level': 0.37; 'subject:: ': 0.38; 'think': 0.40; 'easy': 0.60; 'most': 0.61; 'first': 0.61; 'more': 0.63; 'become': 0.65; 'fact,': 0.69; '01:57': 0.84; 'fourth': 0.84; 'subject:else': 0.84; '"it': 0.91
Date Wed, 28 Nov 2012 14:08:15 -0600
From Evan Driscoll <driscoll@cs.wisc.edu>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:10.0.10) Gecko/20121026 Thunderbird/10.0.10
MIME-Version 1.0
To Ian Kelly <ian.g.kelly@gmail.com>
Subject Re: Re: re.search when used within an if/else fails
References <f0f27287-17ea-4fa5-ad26-ad2b6d3c0031@googlegroups.com> <50aadbe6$0$29983$c3e8da3$5496439d@news.astraweb.com> <50aadcf0$0$29983$c3e8da3$5496439d@news.astraweb.com> <a14abf7d-b231-4cf5-989a-f38e6307867d@googlegroups.com> <mailman.82.1353440253.29569.python-list@python.org> <2930dc36-9d8f-411d-aa7a-272fe4885ec5@i5g2000yqh.googlegroups.com> <mailman.192.1353560449.29569.python-list@python.org> <11835b30-3448-45cc-9ae5-46d651f93429@googlegroups.com> <CALwzid=MW+c2F_Z_2=npC=Z41FJuFOXYMBJ0N-fGxycJE53t4A@mail.gmail.com>
In-Reply-To <CALwzid=MW+c2F_Z_2=npC=Z41FJuFOXYMBJ0N-fGxycJE53t4A@mail.gmail.com>
X-Enigmail-Version 1.4
Content-Type multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig2051CA9AE17E00279A4BB18C"
Cc Python <python-list@python.org>
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.346.1354133357.29569.python-list@python.org> (permalink)
Lines 67
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1354133357 news.xs4all.nl 6988 [2001:888:2000:d::a6]:59083
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34032

Show key headers only | View raw


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

On 11/28/2012 01:57 PM, Ian Kelly wrote:
> Yes, it's best to use either tabs-only or spaces-only.  Quoting from PEP
> 8 on the subject:
> 
>     Never mix tabs and spaces.
> 
>     The most popular way of indenting Python is with spaces only. The
>     second-most popular way is with tabs only. Code indented with a
>     mixture of tabs and spaces should be converted to using spaces
>     exclusively. When invoking the Python command line interpreter with
>     the -t option, it issues warnings about code that illegally mixes
>     tabs and spaces. When using -tt these warnings become errors. These
>     options are highly recommended!
> 
>     For new projects, spaces-only are strongly recommended over tabs.
>     Most editors have features that make this easy to do.
> 
> 
> I thought the prohibition against mixing tabs and spaces was made more
> strict in Python 3, but I can't find any reference to that now. 
> Probably I was mistaken.

I'm only entering this thread now so I'm not really in context, but
you're correct; in Python 3, -tt is set by default, which makes illegal
mixing an error.

However, not all mixing is illegal: what it means by "code that
illegally mixes tabs and spaces" is "code whose interpretation differs
depending upon the interpretation of the tab width". While I'm not going
to go test it, I think that if you, say, indent from the first to the
second level with tabs (consistently), indent from the second to third
level with spaces (consistently), and indent from the third to fourth
level with tabs (consistently), it should not complain. Or perhaps I
should say "it should complain that you're a bad person and should feel
bad, but it won't." :-) (In fact, you could indent one block at the
second level with tabs and another with spaces.)

Evan

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


Thread

re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-19 15:43 -0800
  Re: re.search when used within an if/else fails MRAB <python@mrabarnett.plus.com> - 2012-11-20 01:21 +0000
  Re: re.search when used within an if/else fails Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-20 01:24 +0000
    Re: re.search when used within an if/else fails Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-20 01:29 +0000
      Re: re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-20 11:09 -0800
        Re: re.search when used within an if/else fails Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-20 12:37 -0700
          Re: re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-21 08:41 -0800
            Re: re.search when used within an if/else fails Chris Angelico <rosuav@gmail.com> - 2012-11-22 16:00 +1100
              Re: re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-28 11:39 -0800
                Re: Re: re.search when used within an if/else fails Evan Driscoll <driscoll@cs.wisc.edu> - 2012-11-28 14:08 -0600
                Re: re.search when used within an if/else fails Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-28 21:39 +0000
                Re: re.search when used within an if/else fails Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-28 19:20 -0500
                Re: re.search when used within an if/else fails Duncan Booth <duncan.booth@invalid.invalid> - 2012-11-29 09:34 +0000
                Re: re.search when used within an if/else fails Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-29 13:38 -0500
                RE: re.search when used within an if/else fails "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-29 22:57 +0000
                RE: re.search when used within an if/else fails "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-29 22:53 +0000
              Re: re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-28 11:39 -0800
                Re: re.search when used within an if/else fails Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-28 20:50 +0000
        Re: re.search when used within an if/else fails Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-20 12:39 -0700

csiph-web