Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '#if': 0.05; 'clause': 0.07; 'executed': 0.07; 'python': 0.09; 'both.': 0.16; 'made-up': 0.16; 're.search(': 0.16; 'subject:fails': 0.16; 'subject:when': 0.16; 'wrote:': 0.17; 'kevin': 0.23; 'tried': 0.25; 'header:In- Reply-To:1': 0.25; 'values': 0.26; '2.3': 0.27; 'message- id:@mail.gmail.com': 0.27; 'subject:/': 0.28; 'testing.': 0.29; "skip:' 20": 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'nov': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; '20,': 0.65; 'fortunately,': 0.84; 'subject:else': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=JNsISSGc4+p5uZKqXSit0JXPzh95xOkIVscbOupbhm0=; b=MLjX+9V2AovQEyy+Z6t58N8egbVbx2S2WiHdxGn9vwsB9+WyDAgMfSA48p4SKhOqJw /n7mE0Eyb/uAhPUyITC/qogs2DcFv1ivN3IgklfhEagqDAyE3Ilar5953ha3LQaxR+Zo Ol5HUN2X89Si6XjqfpWdPwnURm0yW9bAaE0fBvA+3nh4UKrqIXh7OefiQROLrgeOoGjK Dy2IPYGonVjaMQUN1Cut3Y+sq6nFMD3wDRCGg8Ww3px8hR/PM8QnEX4LXhYa0TZuVGBE VD8W8psHORhO4KZiXVGqsVAKz0dhCxyGd1sL+BPGvl85ISJlG7iQOouXogcIDILYpbIO CP+Q== MIME-Version: 1.0 In-Reply-To: References: <50aadbe6$0$29983$c3e8da3$5496439d@news.astraweb.com> <50aadcf0$0$29983$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Tue, 20 Nov 2012 12:37:01 -0700 Subject: Re: re.search when used within an if/else fails To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353440253 news.xs4all.nl 6844 [2001:888:2000:d::a6]:54446 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33649 On Tue, Nov 20, 2012 at 12:09 PM, Kevin T 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.