This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author BTaskaya
Recipients BTaskaya, JohnPie
Date 2020-11-09.10:54:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1604919283.5.0.801865657836.issue42295@roundup.psfhosted.org>
In-reply-to
Content
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)
History
Date User Action Args
2020-11-09 10:54:43BTaskayasetrecipients: + BTaskaya, JohnPie
2020-11-09 10:54:43BTaskayasetmessageid: <1604919283.5.0.801865657836.issue42295@roundup.psfhosted.org>
2020-11-09 10:54:43BTaskayalinkissue42295 messages
2020-11-09 10:54:43BTaskayacreate