Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33649
| 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> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2012-11-20 12:37 -0700 |
| Subject | Re: re.search when used within an if/else fails |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.82.1353440253.29569.python-list@python.org> (permalink) |
On Tue, Nov 20, 2012 at 12:09 PM, Kevin T <kevinintx@gmail.com> wrote:
> #if re.search( "rsrvd", sigName ) : #version a
> #if re.search( "rsrvd", sigName ) == None : #version b
> if re.search( "rsrvd", sigName ) is None : #version bb
> print sigName
> newVal = "%s%s" % ('1'*signal['bits'] , newVal )
> #else: #version c
> if re.search( "rsrvd", sigName ) != None : #version d
> print sigName
> newVal = "%s%s" % ( '0'*signal['bits'],> newVal )
>
> i can use either version a/b the else clause (version c) will not execute.
> fortunately, with version bb, the else clause will execute!!
There must be some other difference in your testing. I don't have
Python 2.4 available, but I tried your version a in both Python 2.3
and 2.5 using made-up values for sigName, and the else clause is
executed in both.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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