Issue 4857: syntax: no unpacking in augassign (original ) (raw )Created on 2009-01-06 13:11 by jura05 , last changed 2022-04-11 14:56 by admin . This issue is now closed .
Messages (6)
msg79256 - (view)
Author: jura (jura05)
Date: 2009-01-06 13:11
the following code produces syntax error: >>> (x, y) += 1 While this is documented in http://docs.python.org/3.0/reference/simple_stmts.html#augmented-assignment-statements ("An augmented assignment evaluates the target (which, unlike normal аssignment statements, cannot be an unpacking)..."), the syntax specification doesn't reflect this: http://docs.python.org/3.0/reference/simple_stmts.html#grammar-token-augmented_assignment_stmt http://docs.python.org/3.0/reference/grammar.html
msg79258 - (view)
Author: STINNER Victor (vstinner) *
Date: 2009-01-06 13:18
Extract of the grammar: target ::= identifier | ... target_list ::= target ("," target)* [","] assignment_stmt ::= (target_list "=")+ ... augmented_assignment_stmt ::= target augop ... augop ::= "+="
... So there is only one possible target for "... += ..." and multiple targets for "... = ..".
msg79260 - (view)
Author: jura (jura05)
Date: 2009-01-06 13:23
Yes, but target ::= identifier | "(" target_list ")"
... so (x,y) seems to be a valid target.
msg79262 - (view)
Author: STINNER Victor (vstinner) *
Date: 2009-01-06 13:33
Oh yes! I didn't see "(" target_list ")" | "[" target_list "]", sorry.
msg79515 - (view)
Author: Terry J. Reedy (terry.reedy) *
Date: 2009-01-09 21:55
The grammar in the doc is not the one used to generate the parser/compiler. The former is meant to be easier for humans to read, the latter easier for the parser generator. Neither completely embody Python's syntax rules. Additional restrictions may be applied later in the chain. From: http://svn.python.org/view/python/trunk/Grammar/Grammar?rev=65872&view=auto expr_stmt: testlist (augassign (yield_expr|testlist)
('=' (yield_expr
testlist))*) augassign: ('+='
'-='
'*='
'/='
'%='
'&='
'
='
'^='
'<<='
'>>='
msg80099 - (view)
Author: Georg Brandl (georg.brandl) *
Date: 2009-01-18 13:47
Fixed in r68725 .
History
Date
User
Action
Args
2022-04-11 14:56:43
admin
set
github: 49107
2009-01-18 13:47:52
georg.brandl
set
status: open -> closedresolution: fixedmessages: +
2009-01-09 21:55:38
terry.reedy
set
nosy: + terry.reedy messages: +
2009-01-06 13:33:24
vstinner
set
messages: +
2009-01-06 13:23:38
jura05
set
messages: +
2009-01-06 13🔞48
vstinner
set
nosy: + vstinner messages: +
2009-01-06 13:11:53
jura05
create