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
Copy file name to clipboardExpand all lines: README.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ So, here we go...
65
65
-[> The out of scope variable/外部作用域变量](#-the-out-of-scope-variable外部作用域变量)
66
66
-[> Be careful with chained operations/小心链式操作](#-be-careful-with-chained-operations小心链式操作)
67
67
-[> Name resolution ignoring class scope/忽略类作用域的名称解析](#-name-resolution-ignoring-class-scope忽略类作用域的名称解析)
68
-
-[> Needle in a Haystack](#-needle-in-a-haystack)
68
+
-[> Needle in a Haystack/大海捞针](#-needle-in-a-haystack大海捞针)
69
69
-[Section: The Hidden treasures!](#section-the-hidden-treasures)
70
70
-[> Okay Python, Can you make me fly? *](#-okay-python-can-you-make-me-fly-)
71
71
-[> `goto`, but why? *](#-goto-but-why-)
@@ -1844,7 +1844,7 @@ class SomeClass:
1844
1844
1845
1845
---
1846
1846
1847
-
### > Needle in a Haystack
1847
+
### > Needle in a Haystack/大海捞针
1848
1848
1849
1849
1\.
1850
1850
```py
@@ -1853,11 +1853,11 @@ x, y = (0, 1) if True else None, None
1853
1853
1854
1854
**Output:**
1855
1855
```
1856
-
>>> x, y # expected (0, 1)
1856
+
>>> x, y # 期望的结果是 (0, 1)
1857
1857
((0, 1), None)
1858
1858
```
1859
1859
1860
-
Almost every Python programmer has faced a similar situation.
1860
+
几乎每个 Python 程序员都遇到过类似的情况.
1861
1861
1862
1862
2\.
1863
1863
```py
@@ -1883,10 +1883,10 @@ e
1883
1883
tuple()
1884
1884
```
1885
1885
1886
-
#### 💡 Explanation:
1887
-
* For 1, the correct statement for expected behavior is `x, y = (0, 1) if True else (None, None)`.
1888
-
* For 2, the correct statement for expected behavior is `t = ('one',)` or `t = 'one',` (missing comma) otherwise the interpreter considers `t` to be a `str` and iterates over it character by character.
1889
-
* `()` is a special token and denotes empty `tuple`.
1886
+
#### 💡 说明:
1887
+
* 对于 1, 正确的语句是 `x, y = (0, 1) if True else (None, None)`.
0 commit comments