Title: can you add this new feature about grammar?
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.9
Status: closed Resolution: postponed
Dependencies: Superseder:
Assigned To: Nosy List: aeros, dai dai, steven.daprano, xtreak
Priority: normal Keywords:

Created on 2019-07-13 06:50 by dai dai, last changed 2019-07-13 07:28 by steven.daprano. This issue is now closed.

Messages (6)
msg347779 - (view) Author: dai dai (dai dai) Date: 2019-07-13 06:50
>> a = 1
>> b = 2
>> a, b += 1, 2
2  3
msg347780 - (view) Author: dai dai (dai dai) Date: 2019-07-13 06:51
>> a = 1
>> b = 2
>> a, b += 1, 2
2, 4
msg347781 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-07-13 07:17
Changes like this needs to be discussed in python-ideas first . The current behavior is as below : 

>>> a, b += 1, 2
  File "<stdin>", line 1
SyntaxError: illegal expression for augmented assignment

See also for some reference to the initial PEP proposal :

There is also a comment related to this where this error is raised

Augmented assignments can only have a name, a subscript, or an
attribute on the left, though, so we have to explicitly check for

I would propose closing this now and reopening this if there is some consensus on moving forward with this in python-ideas.
msg347782 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-07-13 07:23
A new language feature like this needs to be discussed on Python-Ideas first, to get community feedback, to decide whether the feature is desired by the community, to iron-out any bugs in the specification, and decide whether or not you will need to write a PEP first. (You probably will.)

Until then, I'm closing this as Postponed.
msg347783 - (view) Author: Kyle Stanley (aeros) * (Python committer) Date: 2019-07-13 07:24
Thanks for the suggestion.

Personally I wouldn't be in favor of this particular change. It doesn't add any additional functionality beyond saving a couple of characters. Also, this could quickly get rather convoluted. For separation and clarity, the assignment operators ("+=", "-=", "/=", "*=", etc) should affect one variable. If you wanted to fit multiple on the same line, you could simply use:

>>> a += 1; b += 2
msg347784 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-07-13 07:28
Oops, I accidentally removed xtreak, and then aeros167 accidentally removed me.
Date User Action Args
2019-07-13 07:28:59steven.dapranosetnosy: + steven.daprano, xtreak
type: enhancement
messages: + msg347784
2019-07-13 07:24:42aerossetnosy: + aeros, - steven.daprano
type: enhancement -> (no value)
messages: + msg347783
2019-07-13 07:23:01steven.dapranosetstatus: open -> closed

type: enhancement
components: + Interpreter Core
versions: + Python 3.9
nosy: + steven.daprano, - xtreak
messages: + msg347782
resolution: postponed
stage: resolved
2019-07-13 07:17:09xtreaksetnosy: + xtreak
messages: + msg347781
2019-07-13 06:51:49dai daisetmessages: + msg347780
2019-07-13 06:50:47dai daicreate