Feature suggestion -- return if true
nobody at nowhere.com
Tue Apr 12 08:08:37 CEST 2011
On Tue, 12 Apr 2011 13:01:43 +1000, James Mills 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.
What the OP actually said was:
> I propose the following syntax:
> return? expr
> be expanded to
> _temp = expr
> if _temp: return _temp
It should be abundantly clear that this only returns if the expression is
considered true, otherwise it continues on to the following statements.
More information about the Python-list