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-8
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-)
@@ -1849,7 +1849,7 @@ class SomeClass:
1849
1849
1850
1850
---
1851
1851
1852
-
### > Needle in a Haystack
1852
+
### > Needle in a Haystack/大海捞针
1853
1853
1854
1854
1\.
1855
1855
```py
@@ -1858,11 +1858,11 @@ x, y = (0, 1) if True else None, None
1858
1858
1859
1859
**Output:**
1860
1860
```
1861
-
>>> x, y # expected (0, 1)
1861
+
>>> x, y # 期望的结果是 (0, 1)
1862
1862
((0, 1), None)
1863
1863
```
1864
1864
1865
-
Almost every Python programmer has faced a similar situation.
1865
+
几乎每个 Python 程序员都遇到过类似的情况.
1866
1866
1867
1867
2\.
1868
1868
```py
@@ -1888,10 +1888,10 @@ e
1888
1888
tuple()
1889
1889
```
1890
1890
1891
-
#### 💡 Explanation:
1892
-
* For 1, the correct statement for expected behavior is `x, y = (0, 1) if True else (None, None)`.
1893
-
* 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.
1894
-
* `()` is a special token and denotes empty `tuple`.
1891
+
#### 💡 说明:
1892
+
* 对于 1, 正确的语句是 `x, y = (0, 1) if True else (None, None)`.
0 commit comments