Feature suggestion -- return if true
Grant Edwards
invalid at invalid.invalid
Tue Apr 12 09:44:03 EDT 2011
On 2011-04-12, James Mills <prologic at shortcircuit.net.au> wrote:
> On Tue, Apr 12, 2011 at 12:44 PM, Chris Angelico <rosuav at gmail.com> 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 ...
More information about the Python-list
mailing list