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


Groups > comp.lang.python > #34044

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

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: re.search when used within an if/else fails
Date 2012-11-28 19:20 -0500
Organization > Bestiaria Support Staff <
References (3 earlier) <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> <mailman.346.1354133357.29569.python-list@python.org> <50b68476$0$29994$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.352.1354148444.29569.python-list@python.org> (permalink)

Show all headers | View raw


On 28 Nov 2012 21:39:03 GMT, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> declaimed the following in
gmane.comp.python.general:

> On Wed, 28 Nov 2012 14:08:15 -0600, Evan Driscoll wrote:
> 
> > 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. 
> 
> Correct, which disappoints me. Testing with Python 3:
> 
> py> if True:
> ...     if True: # tab
> ...         pass  # tab, then four spaces
> ...
> py>
> 
> I would prefer that the "pass" line would fail with an illegal indent, 
> but it does not. But at least the following fails cleanly:
> 
> 
> py> if True:
> ...     if True: # tab
> ...         pass  # tab, then four spaces
> ...         pass  # two spaces, tab, four spaces
>   File "<stdin>", line 4
>     pass  # two spaces, tab, four spaces
>                                        ^
> TabError: inconsistent use of tabs and spaces in indentation
>

	Unless there has been a major change in the parser... (I still don't
have Python 3.x installed)

	I believe <tab> is expanded to 8-spaces -- NOT TO NEXT MULTIPLE OF
8...

	So the first is 8+4 => 12 spaces, the second is 2+8+4 => 14 spaces.

	Does 2 + <tab> + 2 vs 4 + <tab> vs <tab> + 4 succeed? That would
confirm the treatment. 

	The main concern with mixed tab and spaces, as I recall, was due to
having /editors/ and /terminals/ configured to show <tab> as a four
space (or anything other than an eight space) increment; so visually
four spaces and one <tab> might look the same... One user might have the
editor showing 4-space indents on <tab> but entering text using 4 spaces
on input -- which now is mis-aligned if the source file HAD <tab> in it.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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