Python: Ous de Pasqua

Efectivament, Python fa homenatge als Monty Python (que és d’on va sortir el nom) i té alguns ous de pasqua ben divertits o curiosos:

Per exemple, si estem a Python 3.0 podem cridar al mòdul antigravity:

 >>> import antigravity 

I se’ns obrirà una finestra a una tira còmica de XKCD (que, per cert, recomano moltíssim). Si no estem a Python 3.0, podem fer això:

>>>import webbrowser
>>>webbrowser.open("http://xkcd.com/353/")

I farà el mateix efecte.

Un altre seria fer:

>>> import this
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!

Això ens dóna el codi Zen de Python :) A més, si ara fem print this.sens donarà el mateix codi Zen però amb les lletres de les paraules substituides per altres.

Un altre seria:

>>> import __hello__
Hello world...

I l’últim de tots és:

>>> from __future__ import braces
SyntaxError: not a chance (<pyshell#4>, line 1)
Aquesta entrada es va publicar dins de Programació i etiquetat com a . Guarda l'enllaç permanent. Deixa un comentari o deixa un trackback: URL del trackback.

Deixa un comentari

No es publicarà ni es compartirà mai el teu correu electrònic. Els camps obligatoris estan marcats amb *

*
*

Pots fer servir aquestes etiquetes i atributs HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>