Op 23/10/2021 om 03:22 schreef Stefan Ram: > Paulo da Silva <p_d_a_s_i_l_v_a...@nonetnoaddress.pt> writes: >> Well, I didn't follow the discussion of this new feature, but the reason >> I can see behind allowing it seems so valid for for ctr:=ctr-1 as for >> self.ctr:=self.ctr-1. The kind of use is exactly the same. One is for a >> normal function, the other for a method. > The intention of the introduction of the assignment expression > was to allow grab the values of subexpressions so as to be able > to later use these value. This can be done with an identifier: > > if env_base := os.environ.get( "PYTHONUSERBASE", None ): > return env_base > > . I am wondering what use cases are there for having something > different than an identifier on the left side.
Well I have the following use case: while (temp_result := calculate_next_couple(a, b))[1]: a, b = temp_result more calculations Which IMO would be clearer if I could just write: while ((a, b) := calculate_next_couple(a,b))[1]: more calculations Of course it would even more clear if I could write something like: while (a, b) := calculate_next_couple(a, b); b: more calculations or do: a, b = calculate_next_couple(a, b) while b: more calculations -- Antoon. -- https://mail.python.org/mailman/listinfo/python-list