You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2020-11-09.12:44:05.710>created_at=<Date2020-11-09.10:48:14.577>labels= ['build', 'invalid', '3.9']
title='Error should be flagged if Walrus operator is used for multiple assigment'updated_at=<Date2020-11-09.12:44:05.710>user='https://github.com/JohnPie'
#The 'Walrus' operator does not support multiple assignment but does not #flag an attempt to make a multiple assigment as an error
#This results in unexpected behavior at execution time:
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
= RESTART: C:\Users\John PC 2017\AppData\Local\Programs\Python\Python38-32\walrustest.py
100 200
found true
100 3
>>>
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.
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)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: