Feature suggestion -- return if true

Martin v. Loewis martin at v.loewis.de
Sun Apr 17 06:03:28 EDT 2011


>> be expanded to
>>
>>    _temp = expr
>>    if _temp: return _temp
> 
> This could be simplified to just:
> 
> return expr or None
> """

No, it can't be simplified in this way.
If there is code after that snippet, then
it will get executed in the original version if _temp is
false, but won't get executed in your simplification.

Regards,
Martin



More information about the Python-list mailing list