Skip to content

Commit 8f298c6

Browse files
committed
Fixed the incorrect part in "Associativity"
Python doesn't treat `a = b = c` as `a = (b = c)`. It's more like `temp = c`, then `a = temp`, followed by `b = temp`.
1 parent 687239f commit 8f298c6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

op_exp.asciidoc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,18 @@ expression, then you can write something like `(2 + 3) * 4`.
227227
=== Associativity
228228

229229
Operators are usually associated from left to right. This means that operators with the same
230-
precedence are evaluated in a left to right manner. For example, `2 + 3 + 4` is evaluated as `(2 +
231-
3) + 4`. Some operators like assignment operators have right to left associativity i.e. `a = b = c`
232-
is treated as `a = (b = c)`.
230+
precedence are evaluated in a left to right manner. For example, `2 + 3 + 4` is evaluated as `(2 + 3) + 4`.
231+
232+
Assignment operators are the same. For example, `a = b = c` is treated as:
233+
234+
[source,python]
235+
--------------------------------------------------
236+
temp = c
237+
a = temp
238+
b = temp
239+
--------------------------------------------------
240+
241+
In this case `temp` is a temporary variable, actually it does not exist, or we can say it will be deleted then.
233242

234243
=== Expressions
235244

0 commit comments

Comments
 (0)