New assignmens ...

Antoon Pardon antoon.pardon at
Wed Oct 27 13:01:44 EDT 2021

Op 27/10/2021 om 18:16 schreef Christman, Roger Graydon:
> 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?

Because this is about a general idea, not about the specifics of the example.
> 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.

Do you have a procedure that will always eliminate a list and will be
more or less as readable as the one and a half loop?

I know the list serves no purpose, other than to provide a way to
easily write the calculations in the order that seems most natural.

But being able to write calculations in the order that makes them
more understandable is IMO worth more than eliminating the list.
Even if the list serves no real purpose in the calculations.

So suppose I have an arbitrary number of simple statements. The
latter possible using results from previous assignment and at the
end a condition to control the one and a half loop. How do you write
the python code so that the one and a half loop is easy to recognize?

Antoon Pardon

More information about the Python-list mailing list