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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'received:209.85.212.46': 0.03; 'received:mail-vw0-f46.google.com': 0.03; 'equivalent.': 0.09; 'terminate': 0.09; 'pm,': 0.11; 'def': 0.13; 'wrote:': 0.14; 'expr': 0.16; 'none"': 0.16; 'otherwise,': 0.20; 'tue,': 0.20; 'header:In-Reply-To:1': 0.22; 'jason': 0.22; 'here?': 0.23; 'received:209.85.212': 0.25; 'subject: -- ': 0.25; 'chris': 0.27; 'function': 0.27; 'hey': 0.29; 'argue': 0.31; 'second': 0.31; 'to:addr:python-list': 0.32; 'from:charset:iso-8859-1': 0.33; 'received:192.168.1': 0.34; 'received:192': 0.34; 'point': 0.35; 'function.': 0.35; 'none': 0.36; 'received:192.168': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'header:Mime-Version:1': 0.39; 'would': 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'said:': 0.68; 'message- id:@localhost.localdomain': 0.74; '12:18': 0.84; '12:20': 0.84; '12:44': 0.84; 'death!': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:in-reply-to:references :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=kwF03kMydtBQ7LY+UyrrL7xic40AHWsR+M/Syrw0B+I=; b=yCjJSl/Vxt8LvG1ZNy9Zbl20/4qsNYY/WpjMcWhdMLQNqXu6Ud6vZW5Pbvkp7k996o sKFwnOPFBcjQUOqLkdUNgYpkQHvXOy70DCPcmXvjjxDkTdfL2kgXF6ufy1qQQJHwSpz/ qGzYu2MLxS42r7xqVwOlWNtG+M59P/loUyrl4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:in-reply-to:references:content-type:date:message-id :mime-version:x-mailer:content-transfer-encoding; b=qF6oMx1pKYu6gGe3A4IwVtnzfNOzTpKEpz5z4vLXuPZ7Pe7lIES014X2D1Jh1q7Mid KzNfyCYCy7ry+qg1ASt2ifYfxmn7xpxyAZUEiVUkPDj4+eqxZ5h3LnaNgsv/s0tm2twL T+AiKEUz5Him1n6JyIp3dyqK/tUuPPWeVjenQ= Subject: Re: Feature suggestion -- return if true From: Westley =?ISO-8859-1?Q?Mart=EDnez?= To: python-list@python.org In-Reply-To: References: <8abff237-5ccd-4eb6-85c8-cdc9e87520b7@bl1g2000vbb.googlegroups.com> Content-Type: text/plain; charset="UTF-8" Date: Tue, 12 Apr 2011 07:05:38 -0700 Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 7bit 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: 26 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1302617154 news.xs4all.nl 41117 [::ffff:82.94.164.166]:59442 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3051 On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote: > On Tue, Apr 12, 2011 at 12:20 PM, James Mills > wrote: > > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails wrote: > >> This is only true if n < 5. Otherwise, the first returns None and the > >> second returns False. > > > > Which is why I said: > > > > return expr or None > > > > But hey let's argue the point to death! > > That's still not equivalent. "return expr or None" will always > terminate the function. The OP's request was for something which would > terminate the function if and only if expr is non-false. > > Chris Angelico def bs(x): while not x: return x Am I wrong here?