Skip to content

Commit ba6870a

Browse files
committed
Shots fired!y
1 parent 33b38f1 commit ba6870a

File tree

2 files changed

+95
-2
lines changed

2 files changed

+95
-2
lines changed

README.md

+59-2
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,72 @@ from __future__ import braces
445445
SyntaxError: not a chance
446446
```
447447
448-
Braces? No way! You better use Javascript instead.
448+
Braces? No way! If you think that's disappointing, use Java.
449449
450450
#### 💡 Explanation:
451451
+ The `__future__` module is normally used to provide features from future versions of Python. The "future" here is however ironic.
452452
+ This is an easter egg concerned with the community's feelings on this issue.
453453
454454
---
455455
456-
### Okay Python, Can you alter gravity?
456+
### "this" is love :heart:
457+
458+
```py
459+
import this
460+
```
461+
462+
Wait, what's **this**?
463+
464+
**Output:**
465+
```
466+
The Zen of Python, by Tim Peters
467+
468+
Beautiful is better than ugly.
469+
Explicit is better than implicit.
470+
Simple is better than complex.
471+
Complex is better than complicated.
472+
Flat is better than nested.
473+
Sparse is better than dense.
474+
Readability counts.
475+
Special cases aren't special enough to break the rules.
476+
Although practicality beats purity.
477+
Errors should never pass silently.
478+
Unless explicitly silenced.
479+
In the face of ambiguity, refuse the temptation to guess.
480+
There should be one-- and preferably only one --obvious way to do it.
481+
Although that way may not be obvious at first unless you're Dutch.
482+
Now is better than never.
483+
Although never is often better than *right* now.
484+
If the implementation is hard to explain, it's a bad idea.
485+
If the implementation is easy to explain, it may be a good idea.
486+
Namespaces are one honking great idea -- let's do more of those!
487+
```
488+
489+
It's the Zen of Python!
490+
491+
```py
492+
>>> love = this
493+
>>> this is love
494+
True
495+
>>> love is True
496+
False
497+
>>> love is False
498+
False
499+
>>> love is not True or False
500+
True
501+
>>> love is not True or False; love is love # Love is complicated
502+
True
503+
```
504+
505+
#### 💡 Explanation:
506+
507+
* `this` module in Python is an easter egg for The Zen Of Python ([PEP 20](https://www.python.org/dev/peps/pep-0020)).
508+
* And if you think that's already interesting enough, check out the implementation of [this.py](https://hg.python.org/cpython/file/c3896275c0f6/Lib/this.py). Interestingly, the code for the Zen violates itself (and that's probably the only place where this happens).
509+
* Regarding the statement `love is not True or False; love is love`, ironic, but it's self-explanatory.
510+
511+
---
512+
513+
### Okay Python, Can you make me fly?
457514
458515
Well, here you go
459516

parse_readme.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import pprint
2+
3+
fname = "README.md"
4+
snipepts = []
5+
6+
with open(fname, 'r') as f:
7+
lines = f.readlines()
8+
iterator
9+
while iterator:
10+
# check if it's a H3
11+
if line.startswith("###"):
12+
title = line.replace("### ", "")
13+
description = ''
14+
next_line = itertor.next
15+
while not next_line.startswith("#### "):
16+
# store lines till an H4 (explanation) is encountered
17+
description.append(next_line)
18+
next_line = iterator.next
19+
# store lines again until --- or another H3 is encountered
20+
snippets.append({
21+
"title":,
22+
"description":,
23+
"explanation":
24+
})
25+
# repeat until EOL is encoutered
26+
27+
# separating by category
28+
categories = ["a", "b", "c"]
29+
30+
snips_by_cat = {k:[] for k in categories}
31+
32+
for snip in snippets:
33+
cat = raw_input(snip["title"])
34+
snips_by_cat[cat].append(snip)
35+
36+
pprint.pprint(snips_by_cat)

0 commit comments

Comments
 (0)