从前有座山,山里有条蛇。
有一天它生了一堆蛋,它们的名字叫蛇蛋…
为什么叫蛇蛋?
因为电影里面有一个好玩的东西叫…彩蛋。
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
https://xueqiu.com/4942564821...
Python 作为一门开源的语言,社区菊苣们贡献了很多搞笑有趣的东西。
至于为什么贡献这个,我经过缜密的思考,终于想通了这个问题…
这个得从盘古开天辟地说起~
啊不,从开源说起。
开源是什么呢?
顾名思义,就是开除程序员…
你想啊
程序员被开除了…
没有工作…
没有女朋友…
时间大把…
那他能干点什么呢?
玩儿丫
想明白这个问题,我感觉我简直是个天才。总而言之,上面这番伟大的言论就是
0x00 Hello world
Hello world 这个词相信大家都很熟了,当年毛都不会的我跑出来的第一个程序就是 Hello world,那天阳光明媚,那天万里无云,那天我喜极而泣…
但当初的我竟然还要自己敲,在 Python 里,有一个隐藏库,它竟然…
`>>> import __hello__
Hello world!`
* 1
* 2
竟然可以输出 Hello world !
我的天,这得是多无聊,啊不,多有趣啊…
好像不太聪明的亚子…
0x01 巧妙的运用大括号
想当年我写得了一手流利的 C 代码,大括号用的出神入化,无处不括号成了我写代码的风格…
想当年我还和别人为“大括号是放在一行结尾还是另起一行”争论不休,撸起袖子,指点江山激扬文字…
而我接触了 Python 以后,这门神奇的语言,竟然省去了大括号,我无比想念它,为此我还吟诗一首…
啊,大括号~
我,想念你!
后来我发现了 braces 库可以使用大括号的功能,我激动的像个帕金森症的晚期患者,哆里哆嗦的导入库,然后…
`>>> from __future__ import braces
File "", line 1
SyntaxError: not a chance`
* 1
* 2
* 3
哈???
Not a chance???
#¥_+&¥#%&_¥%##
`future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
...
else if (strcmp(feature, "braces") == 0) {
PyErr_SetString(PyExc_SyntaxError,
"not a chance");
PyErr_SyntaxLocation(filename, s->lineno);
return 0;
}`
* 1
* 2
* 3
* 4
* 5
* 6
* 7
* 8
大家欣赏一下源码,我敬他是个人才…
0x02 一个由键盘距离引发的离奇事件
某巨擘觉得在键盘上不等于“!=”隔的太远了,用多了会手指疼,于是在他退休的时候,创建了一个库,一旦导入这个库,判断不相等就只能用“<>”:
`>>> from __future__ import barry_as_FLUFL
>>> "Python" <> "C++"
True
>>> "Python" != "C++"
File "", line 1
"Python" != "C++"
^
SyntaxError: with Barry as BDFL, use '<>' instead of '!='`
* 1
* 2
* 3
* 4
* 5
* 6
* 7
* 8
这个我是真服气的…
不知道他在写这个玩意的时候敲了那么多下键盘,会不会手指疼…
我有一个梦想
希望可以不用写代码...
0x03 一幅厚颜无耻的漫画
输入下面这行代码,你会跳转到一个漫画网页:
`>>> import antigravity`
* 1
网址是: https://xkcd.com/353/
就是上面这个图…
真的是搞笑,都是英文,我怎么看的懂嘛…
一键翻译…
奥,这个我知道,不就是说 Python 语法简单,功能牛批么…
果然是…直接。
0x04 爱是什么?
估计每个 Python 人儿都知道 Python 之禅,不知道也没事,就是下面这个东西:
`>>> import this`
* 1
一键回车:
`The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!`
* 1
* 2
* 3
* 4
* 5
* 6
* 7
* 8
* 9
* 10
* 11
* 12
* 13
* 14
* 15
* 16
* 17
* 18
* 19
* 20
* 21
具体翻译如下:
好好学习
天天向上
this 是什么?
经过我的剽窃,啊不,参考…
this 是爱啊…
`>>> love = this
>>> this is love
True`
* 1
* 2
* 3
那爱是什么?
爱是你我~
用心交织的生活~
错了!
真理告诉我们真理是:
`>>> love is True
False
>>> love is False
False
>>> love is not True or False
True
>>> love is love
True`
* 1
* 2
* 3
* 4
* 5
* 6
* 7
* 8
出处: https://github.com/satwikkans...
程序真的是这个世界上最美的东西…
爱是难言的
我准备把这段代码挂起来,时时刻刻复习…
能写出上面代码的我,真的是会抄啊…
当然了,乱七八糟的蛇蛋还有很多,毕竟开源嘛…
今天就到这儿,拜里个拜~
另外本蒟蒻把公众号的高分原创文章整理成了一本电子书,取名《Python修炼之道》,一共 400 页!
具体内容请戳:熬夜爆肝整理 400 页 《Python 修炼之道》,一本高分原创高清电子书送给你!
目录如下: