Feature suggestion -- return if true
invalid at invalid.invalid
Mon Apr 11 21:44:16 EDT 2011
On 2011-04-12, James Mills <prologic at shortcircuit.net.au> wrote:
> On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 <zildjohn01 at gmail.com> wrote:
>> This is an idea I've had bouncing around in my head for a long time
>> now. I propose the following syntax:
> Maybe this is more appropriare for the python-ideas list ?
>> ?? ??return? expr
> This syntax does not fit well within python ideology.
>> be expanded to
>> ?? ??_temp = expr
>> ?? ??if _temp: return _temp
> This could be simplified to just:
> return expr or None
How is that the same?
return? something() return something() or None
return? somethingelse() return somethingelse() or None
log("didn't find an answer") log("didn't find an answer")
raise ValueError raise ValueError
Are you saying the two snippets above are equivalent?
More information about the Python-list