[issue35207] Disallow expressions like (a) = 42

Serhiy Storchaka report at bugs.python.org
Sat Nov 10 01:04:25 EST 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Actually, `(a) = 42` doesn't contradict the grammar.

assignment_stmt ::=  (target_list "=")+ (starred_expression | yield_expression)
target_list     ::=  target ("," target)* [","]
target          ::=  identifier
                     | "(" [target_list] ")"
                     | "[" [target_list] "]"
                     | attributeref
                     | subscription
                     | slicing
                     | "*" target

So that if we decide to disallow such things, we should change the definition in the language reference.

I thought the code should be similar to the code added in issue34641. But maybe there is a way to simplify both code.

----------
nosy: +benjamin.peterson

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


More information about the Python-bugs-list mailing list