You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [> The mysterious key type conversion/神秘的键型转换 *](#-the-mysterious-key-type-conversion神秘的键型转换-)
52
-
- [> Let's see if you can guess this?](#-lets-see-if-you-can-guess-this)
52
+
- [> Let's see if you can guess this?/看看你能否猜到这一点?](#-lets-see-if-you-can-guess-this看看你能否猜到这一点)
53
53
-[Section: Appearances are deceptive!](#section-appearances-are-deceptive)
54
54
-[> Skipping lines?](#-skipping-lines)
55
55
-[> Teleportation *](#-teleportation-)
@@ -1171,7 +1171,7 @@ str
1171
1171
1172
1172
---
1173
1173
1174
-
### > Let's see if you can guess this?
1174
+
### > Let's see if you can guess this?/看看你能否猜到这一点?
1175
1175
1176
1176
```py
1177
1177
a, b = a[b] = {}, 5
@@ -1183,24 +1183,24 @@ a, b = a[b] = {}, 5
1183
1183
{5: ({...}, 5)}
1184
1184
```
1185
1185
1186
-
#### 💡 Explanation:
1186
+
#### 💡 说明:
1187
1187
1188
-
* According to [Python language reference](https://docs.python.org/2/reference/simple_stmts.html#assignment-statements), assignment statements have the form
> An assignment statement evaluates the expression list (remember that this can be a single expression or a comma-separated list, the latter yielding a tuple) and assigns the single resulting object to each of the target lists, from left to right.
1194
1192
1195
-
* The `+` in `(target_list "=")+` means there can be **one or more** target lists. In this case, target lists are `a, b` and `a[b]` (note the expression list is exactly one, which in our case is `{}, 5`).
* After the expression list is evaluated, it's value is unpacked to the target lists from **left to right**. So, in our case, first the `{}, 5` tuple is unpacked to `a, b` and we now have `a = {}` and `b = 5`.
* `a` is now assigned to `{}` which is a mutable object.
1199
+
* `a` 被赋值的 `{}` 是可变对象.
1200
1200
1201
-
* The second target list is `a[b]` (you may expect this to throw an error because both `a` and `b` have not been defined in the statements before. But remember, we just assigned `a` to `{}` and `b` to `5`).
* Now, we are setting the key `5` in the dictionary to the tuple `({}, 5)` creating a circular reference (the `{...}` in the output refers to the same object that `a` is already referencing). Another simpler example of circular reference could be
0 commit comments