Feature suggestion -- return if true

Nobody nobody at nowhere.com
Tue Apr 12 02:08:37 EDT 2011


On 2011年4月12日 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 mailing list

AltStyle によって変換されたページ (->オリジナル) /