[Python-ideas] if expensive_computation() as x:

Chris Angelico rosuav at gmail.com
Fri Feb 14 05:22:59 CET 2014


On Fri, Feb 14, 2014 at 2:29 PM, Mathias Panzenböck
<grosser.meister.morti at gmx.net> wrote:
> Or if "Do something with x" is always the same:
>
> x = expensive_computation_0() or expensive_computation_1() or
> expensive_computation_2()
>
> if x:
>         # Do something with x...

I would assume that it's not the same... otherwise this method doesn't
just obviate the need for comparison-assignment, it also deduplicates
a block of code. I think most programmers are smart enough to figure
out that that's important :)

ChrisA


More information about the Python-ideas mailing list