Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!news-out.readnews.com!transit3.readnews.com!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Feature suggestion -- return if true Date: Tue, 12 Apr 2011 13:44:03 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 23 Message-ID: References: <8abff237-5ccd-4eb6-85c8-cdc9e87520b7@bl1g2000vbb.googlegroups.com> NNTP-Posting-Host: dsl.comtrol.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reader1.panix.com 1302615843 11452 64.122.56.22 (12 Apr 2011 13:44:03 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Tue, 12 Apr 2011 13:44:03 +0000 (UTC) User-Agent: slrn/pre0.9.9-102 (Linux) Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3046 On 2011-04-12, James Mills wrote: > On Tue, Apr 12, 2011 at 12:44 PM, Chris Angelico wrote: >> 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. > > The OP did not state this at all. > There was never any mention of early termination > of the function iif expr was True. The OP said he wanted something with the semantics of _temp_ = expr if _temp_: return _temp_ That code snippet does not return if expr is false. What you proposed returns None when expr is false. -- Grant Edwards grant.b.edwards Yow! Well, I'm INVISIBLE at AGAIN ... I might as well gmail.com pay a visit to the LADIES ROOM ...