[issue46612] Unclear behavior of += operator

2022-02-02 Thread Marek Scholle
New submission from Marek Scholle : Hi, I ran into discussion about scoping in Python (visibility of outer variables in nested functions, global, nonlocal) which made me to create for other some showcases. I realized there is a space for ambiguity which I extracted to this REPL: >&

[issue46612] Unclear behavior of += operator

2022-02-02 Thread Marek Scholle
Marek Scholle added the comment: Thanks for pointing to reference https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements Although I can agree it tries to point to similarity with `x = x + 1`, it says about how `x += [1]` is processed: (1) evaluate the target

[issue46612] Unclear behavior of += operator

2022-02-02 Thread Marek Scholle
Marek Scholle added the comment: I don't understand the comment https://bugs.python.org/issue46612#msg412374 >>> def f(): x ... >>> f() is OK, so x is something which can be evaluated inside nested function, it is a good target to be used in `x.__i

[issue46612] Unclear behavior of += operator

2022-02-02 Thread Marek Scholle
Marek Scholle added the comment: > a += b means (is closest to) a = type(a).__iadd__(a, b) I exchanged several messages, and this is all I needed! I propose to resolve as "Not a bug" -- ___ Python tracker <https://bugs.pytho