[issue42295] Error should be flagged if Walrus operator is used for multiple assigment

John Zalewski report at bugs.python.org
Mon Nov 9 05:48:14 EST 2020


New submission from John Zalewski <john.zalewski at sfr.fr>:

#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:

a, b = 100, 200

print (a, b)
#result is
#100 200

if (a, b := 3, 4): #this should be flagged as an error but is not



  print ("found true")
else:
  print ("found false")

print (a, b)
#result is
#100 3 but if multiple assigment were allowed this would be '3, 4'


----------------------------------------------------------------------
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
>>>

----------
files: walrustest.py
messages: 380580
nosy: JohnPie
priority: normal
severity: normal
status: open
title: Error should be flagged if Walrus operator is used for multiple assigment
type: compile error
versions: Python 3.9
Added file: https://bugs.python.org/file49583/walrustest.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42295>
_______________________________________


More information about the Python-bugs-list mailing list