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
Python, being a beautifully designed high-level and interpreter-based programming language, provides us with many features for the programmer's comfort. But sometimes, the outcomes of a Python snippet may not seem obvious to a regular user at first sight.
9
10
@@ -13,7 +14,7 @@ While some of the examples you see below may not be WTFs in the truest sense, bu
13
14
14
15
If you're an experienced Python programmer, you can take it as a challenge to get most of them right in first attempt. You may be already familiar with some of these examples, and I might be able to revive sweet old memories of yours being bitten by these gotchas :sweat_smile:
15
16
16
-
If you're a returning reader, you can learn about the new modifications [here](https://github.com/satwikkansal/wtfpython/releases/).
17
+
PS: If you're a returning reader, you can learn about the new modifications [here](https://github.com/satwikkansal/wtfpython/releases/).
17
18
18
19
So, here we go...
19
20
@@ -649,7 +650,7 @@ for x in range(7):
649
650
def some_func():
650
651
return x
651
652
funcs.append(some_func)
652
-
results.append(some_func())
653
+
results.append(some_func())# note the function call here
653
654
654
655
funcs_results = [func() for func in funcs]
655
656
```
@@ -885,10 +886,10 @@ for item in mixed_list:
885
886
886
887
**Output:**
887
888
```py
888
-
>>> booleans_found_so_far
889
-
0
890
889
>>> integers_found_so_far
891
890
4
891
+
>>> booleans_found_so_far
892
+
0
892
893
```
893
894
894
895
2\.
@@ -949,7 +950,7 @@ class C(A):
949
950
pass
950
951
```
951
952
952
-
**Ouptut:**
953
+
**Output:**
953
954
```py
954
955
>>> A.x, B.x, C.x
955
956
(1, 1, 1)
@@ -2016,7 +2017,7 @@ Sshh.. It's a super secret.
2016
2017
#### 💡 Explanation:
2017
2018
+ `antigravity` module is one of the few easter eggs released by Python developers.
2018
2019
+ `import antigravity` opens up a web browser pointing to the [classic XKCD comic](http://xkcd.com/353/) about Python.
2019
-
+ Well, there's more to it. There's **another easter egg inside the easter egg**. If look at the [code](https://github.com/python/cpython/blob/master/Lib/antigravity.py#L7-L17), there's a function defined that purports to implement the [XKCD's geohashing algorithm](https://xkcd.com/426/).
2020
+
+ Well, there's more to it. There's **another easter egg inside the easter egg**. If you look at the [code](https://github.com/python/cpython/blob/master/Lib/antigravity.py#L7-L17), there's a function defined that purports to implement the [XKCD's geohashing algorithm](https://xkcd.com/426/).
2020
2021
2021
2022
---
2022
2023
@@ -2537,7 +2538,7 @@ The idea and design for this collection were initially inspired by Denys Dovhan'
0 commit comments