On 7 Sep 2017, at 13:11, Paul Moore firstname.lastname@example.org wrote:
On 7 September 2017 at 11:43, Denis Krienbühl email@example.com 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.
I see, thank you for digging those threads up. I’ll read them to learn a thing or two :)