[Python-ideas] if <expression> as <variable>

Denis Krienbühl denis at href.ch
Thu Sep 7 07:27:24 EDT 2017


> On 7 Sep 2017, at 13:11, Paul Moore <p.f.moore at gmail.com> wrote:
> 
> On 7 September 2017 at 11:43, Denis Krienbühl <denis at href.ch> wrote:
>> What I would love to see is the following syntax instead, which to me is much cleaner:
>> 
>>   if computation() as result:
>>       do_something_with_result(result)
> 
> Hi - thanks for your suggestion! This has actually come up quite a lot
> in the past. Here's a couple of links to threads you might want to
> read (it's not surprising if you missed these, it's not that easy to
> come up with a good search term for this topic).
> 
> https://mail.python.org/pipermail/python-ideas/2012-January/013461.html
> https://mail.python.org/pipermail/python-ideas/2009-March/003423.html
>  (This thread includes a note by Guido that he intentionally left out
> this functionality)
> 
> In summary, it's a reasonably commonly suggested idea, but there's not
> enough benefit to warrant adding it to the language.
> 
> Paul

I see, thank you for digging those threads up. I’ll read them to learn a thing or two :)


More information about the Python-ideas mailing list