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
+69
Original file line number
Diff line number
Diff line change
@@ -430,6 +430,75 @@ SyntaxError: EOL while scanning string literal
430
430
431
431
---
432
432
433
+
### Brace yourself!
434
+
435
+
If you are one of the people who don't like using whitespace in Python to denote scopes, you can use the C-style {} by importing,
436
+
437
+
```py
438
+
from__future__import braces
439
+
```
440
+
441
+
**Output:**
442
+
```py
443
+
File "some_file.py", line 1
444
+
from__future__import braces
445
+
SyntaxError: not a chance
446
+
```
447
+
448
+
Braces? No way! You better use Javascript instead.
449
+
450
+
#### 💡 Explanation:
451
+
+ The `__future__` module is normally used to provide features from future versions of Python. The "future" here is however ironic.
452
+
+ This is an easter egg concerned with the community's feelings on this issue.
453
+
454
+
---
455
+
456
+
### Okay Python, Can you alter gravity?
457
+
458
+
Well, here you go
459
+
460
+
```py
461
+
import antigravity
462
+
```
463
+
464
+
**Output:**
465
+
Sshh.. It's a super secret.
466
+
467
+
#### 💡 Explanation:
468
+
+`antigravity` module is another easter egg like `from__future__import braces`, with a difference that it actually works.
469
+
+`import antigravity` opens up a web browser pointing to the [classic XKCD comic](http://xkcd.com/353/) about Python.
470
+
+ 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/).
471
+
472
+
---
473
+
474
+
### `goto`, but why?
475
+
476
+
```py
477
+
from goto import goto, label
478
+
for i inrange(9):
479
+
for j inrange(9):
480
+
for k inrange(9):
481
+
print("I'm trapped, please rescue!")
482
+
if k ==2:
483
+
goto .breakout # breaking out from a deeply nested loop
484
+
label .breakout
485
+
print("Freedom!")
486
+
```
487
+
488
+
**Output (Python 2.3):**
489
+
```py
490
+
I'm trapped, please rescue!
491
+
I'm trapped, please rescue!
492
+
Freedom!
493
+
```
494
+
495
+
#### 💡 Explanation:
496
+
- A working version of `goto`in Python was [announced](https://mail.python.org/pipermail/python-announce-list/2004-April/002982.html) as an April Fool's joke on 1st April 2004.
497
+
- Current versions of Python do not have this module.
498
+
- Although it works, but please don't use it. Here's the [reason](https://docs.python.org/3/faq/design.html#why-is-there-no-goto) to why `goto` is not present in Python.
0 commit comments