Responding to your post in different order to the original.
Definitely don't like this syntax - while it might be useful to
On Fri, Feb 14, 2014 at 8:59 AM, Ram Rachum <ram.rachum@gmail.com> wrote:
> If you'd like to bind to a variable only a part of the condition, this would
> work too:
>
> if x<5 with expensive_computation_0() as x:
> # Do something with x
snapshot part of a condition (I've done it in C plenty of times), this
notation feels clumsy. However...
> My suggestion:
>
> if expensive_computation_0() as x:
> # Do something with x...
> elif expensive_computation_1() as x:
> # Do something with x...
> elif expensive_computation_2() as x:
> # Do something with x...
... this simpler form does look reasonable. The "as" part will *only*
come at the end of the expression, and it *always* applies to the
whole expression, so it's fairly clear.