Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33575
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.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; 'sysadmin': 0.05; 'clause': 0.07; 'python': 0.09; '353': 0.16; 'born.': 0.16; 'clause,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'mixture': 0.16; 'none"': 0.16; 'points:': 0.16; 're.search(': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:fails': 0.16; 'subject:when': 0.16; 'tabs': 0.16; 'wrote:': 0.17; 'regardless': 0.21; 'kevin': 0.23; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'this?': 0.28; 'subject:/': 0.28; 'received:192.168.1.3': 0.29; "skip:' 10": 0.30; 'checked': 0.30; 'code': 0.31; 'received:84': 0.32; 'print': 0.32; 'getting': 0.33; 'to:addr:python-list': 0.33; 'version': 0.34; 'there': 0.35; 'anything': 0.36; 'should': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'first': 0.61; 'ever': 0.63; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; '356': 0.84; 'reply-to:addr:python.org': 0.84; 'subject:else': 0.84; 'old.': 0.95 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.0 cv=BusfMPr5 c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=1EKJ2blYo8kA:10 a=ElpWa-wngCoA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=yBAbRxjkyqcA:10 a=7TIVlZT0zJ6bV22JgY8A:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 |
| X-AUTH | mrabarnett:2500 |
| Date | Tue, 20 Nov 2012 01:21:54 +0000 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: re.search when used within an if/else fails |
| References | <f0f27287-17ea-4fa5-ad26-ad2b6d3c0031@googlegroups.com> |
| In-Reply-To | <f0f27287-17ea-4fa5-ad26-ad2b6d3c0031@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | python-list@python.org |
| 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.26.1353374516.29569.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1353374516 news.xs4all.nl 6894 [2001:888:2000:d::a6]:43439 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33575 |
Show key headers only | View raw
On 2012-11-19 23:43, Kevin T wrote: > python version 2.4.3, yes i know that it is old. getting the sysadmin to update the OS requires a first born. > > with the following code.. > for signal in register['signals'] : > > 351 sigName = signal['functionName'] > 352 if re.search( "rsrvd", sigName ) == None : > 353 print sigName > 354 newVal = "%s%s" % ( '1'*signal['bits'] , newVal ) #prepend 0's > 355 if re.search( "rsrvd", sigName ) != None : > 356 print sigName > 357 newVal = "%s%s" % ( '0'*signal['bits'], newVal ) > > regardless of how i code line 352, i can not EVER use an else clause with it. if i use an else clause, the else will NEVER get executed... > > has any one experienced anything like this behavior? any suggestions? the above code works but... why should i have to code it like this? > Have you checked the indentation? There may be a mixture of tabs and spaces. A couple of points: 1. You should be using "is None" and "is not None" instead of "== None" and "!= None". 2. You don't need to use regex. Use "rsrvd" in sigName and "rsrvd" not in sigName.
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