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.

Title: Poor error message for augmented assign
Type: Stage:
Components: Interpreter Core Versions: Python 2.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: bquinlan, brett.cannon, nnorwitz
Priority: normal Keywords:

Created on 2002-11-26 21:22 by bquinlan, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (4)
msg13468 - (view) Author: Brian Quinlan (bquinlan) * (Python committer) Date: 2002-11-26 21:22
>>> [1,2] += [2,3]
SyntaxError: augmented assign to list not possible

A similar error message is generated when augmented 
assignment is used on tuple literals.

This error message is desceptive because augmented 
assignment is allowed on both of those types. 

I would change the message to:

SyntaxError: can't assign to literal

I may generate a patch for this, but not anytime soon.
msg13469 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-12-31 13:16
Logged In: YES 

Jeremy, do you agree?  How about adding the word literal to
the error msg, so it reads:

 * augmented assign to literal list not possible
msg13470 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-05-22 04:05
Logged In: YES 

I like Neal's suggestion.
msg13471 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-05-22 22:01
Logged In: YES 

Checked in Python/compile.c 2.289 to add the word literal
Hopefully this is clearer.

This change could be backported, if anyone cares.
Date User Action Args
2022-04-10 16:05:56adminsetgithub: 37541
2002-11-26 21:22:35bquinlancreate