Message380581
Due to the precedence of the walrus operator, it is not actually a multiple assignment but rather a tuple of 3 elements with one being the value of the assignment expression.
$ python -m ast
(a, b := 3, 4)
Module(
body=[
Expr(
value=Tuple(
elts=[
Name(id='a', ctx=Load()),
NamedExpr(
target=Name(id='b', ctx=Store()),
value=Constant(value=3)),
Constant(value=4)],
ctx=Load()))],
type_ignores=[])
In this case, it creates a tuple with loading the name `a` from the current scope, using the value of the 3 and also assigning 3 to the b, and loading constant 4.
So basically (a, b := 3, 4) is actually (a, (b := 3), 4) |
|
Date |
User |
Action |
Args |
2020-11-09 10:54:43 | BTaskaya | set | recipients:
+ BTaskaya, JohnPie |
2020-11-09 10:54:43 | BTaskaya | set | messageid: <1604919283.5.0.801865657836.issue42295@roundup.psfhosted.org> |
2020-11-09 10:54:43 | BTaskaya | link | issue42295 messages |
2020-11-09 10:54:43 | BTaskaya | create | |
|