Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'expressions.': 0.09; 'subject:string': 0.09; 'wrote:': 0.15; 're.search': 0.16; 'subject:print': 0.16; 'cc:addr:python-list': 0.16; 'pm,': 0.16; '2.x': 0.19; 'string,': 0.19; 'variable': 0.21; 'cc:2**0': 0.21; 'this?': 0.22; 'cc:no real name:2**0': 0.22; 'header:In-Reply- To:1': 0.22; 'assume': 0.23; 'found,': 0.23; 'appear': 0.23; 'string': 0.26; 'function': 0.26; 'message-id:@mail.gmail.com': 0.28; 'thu,': 0.28; 'cc:addr:python.org': 0.30; 'match': 0.30; 'times.': 0.30; 'subject:?': 0.31; 'print': 0.32; "i've": 0.33; 'calling': 0.34; 'received:209.85.161.46': 0.34; 'received:mail- fx0-f46.google.com': 0.34; 'probably': 0.35; 'subject:How': 0.36; 'regular': 0.36; 'response': 0.37; 'received:google.com': 0.37; 'but': 0.37; 'received:209.85': 0.38; 'received:209.85.161': 0.38; 'subject:: ': 0.38; 'run': 0.39; 'received:209': 0.39; 'would': 0.40; 'john': 0.62; 'body': 0.63; 'due': 0.66; 'jun': 0.67; 'subject:you': 0.80 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=v0HEL6r/2uYg0NjvJnDXzQt0ys2Q9vQLi+Ol4ImQvIs=; b=E6UhuMuGLu/DaRHb3wPLfzDb4o/Ze65XVgFluG7o4B0L8qhvxqMRzI8rRtEmk6oJUD F1388mOq1G0L2fKSkR0FPlG2okmQTyqfZQjXLBgC4FF5gQfPIvnbQ9uwQPuQ+S8yiebU jYXoWmvIw2NX6sR9n7TrV4aNE1HUHbvl1vDpM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=uH5sTlki3yYNBv3IawMOqE54frvE+OyMZHSzA3fUn6jp39tyzvp7P9+w/8wlxXk4Df 5P60CSSEBZOJN03jub7ZOAfvRKuReTzFEqLYiLB//8at3anzbKbMlPDRL+bG5JhMPNGO HUCfHWspKIh81+SMQYkiIpYA6JCfKRAgagUeg= MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Thu, 23 Jun 2011 14:47:07 -0600 Subject: Re: How do you print a string after it's been searched for an RE? To: John Salerno Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 10 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308862058 news.xs4all.nl 14135 [::ffff:82.94.164.166]:40464 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8326 On Thu, Jun 23, 2011 at 1:58 PM, John Salerno wrote: > After I've run the re.search function on a string and no match was > found, how can I access that string? When I try to print it directly, > it's an empty string, I assume because it has been "consumed." How do > I prevent this? This has nothing to do with regular expressions. It would appear that page.read() is letting you read the response body multiple times in 2.x but not in 3.x, probably due to a change in buffering. Just store the string in a variable and avoid calling page.read() multiple times.