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: 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 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: In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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.