New assignmens ...
Christman, Roger Graydon
dvl at psu.edu
Wed Oct 27 12:16:11 EDT 2021
On 27/10/2021 at 12:45 Antoon Pardon wrote:
> However with the introduction of the walrus operator there is a
> way to simulate a significant number of one and a half loops.
> Consider the following:
> do
> a = expr1
> b = expr2
> while 2 * a > b:
> more calculations
> We could write that now as
> while [
> a := expr1,
> b := expr2,
> 2 * a > b][-1]:
> more calculations
Why don't you try this?
while 2 * (a := expr1) > (b := expr2):
more calculations
It seems you are just compelled to create tuple and lists
in all of your use-cases, even when they serve no purpose.
Roger Christman
More information about the Python-list
mailing list