◆ import this

Python の記事を見てたときに The Zen of Python というのを見て なんだろうと調べてみたら Python エンジニアの人が書いた どういうコードを書くべきかを書いたものでした

「見苦しいものより美しいもの 暗黙的より明示的」 とかそういう感じのやつです

PEP にもなってます

zen mode とか zen coding とかもありますが zen (禅) って言葉好きな人多いですよね

その The Zen of Python ですが this という名前のパッケージをインポートすれば表示できるようです

Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 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!

出ました
標準ライブラリにこういうのも入ってるんですね
zen ならともかくなんで this なんだろう?

this.py のソースコードを見てみましたが 特にそのあたりには触れられていませんでした
https://github.com/python/cpython/blob/master/Lib/this.py

s = """Gur Mra bs Clguba, ol Gvz Crgref
Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Pbzcyrk vf orggre guna pbzcyvpngrq.
Syng vf orggre guna arfgrq.
Fcnefr vf orggre guna qrafr.
Ernqnovyvgl pbhagf.
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
Nygubhtu cenpgvpnyvgl orngf chevgl.
Reebef fubhyq arire cnff fvyragyl.
Hayrff rkcyvpvgyl fvyraprq.
Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.
Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.
Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.
Abj vf orggre guna arire.
Nygubhtu arire vf bsgra orggre guna *evtug* abj.
Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.
Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""

d = {}
for c in (65, 97):
for i in range(26):
d[chr(i+c)] = chr((i+13) % 26 + c)

print("".join([d.get(c, c) for c in s]))

暗号化されています
と言っても単純に文字を置換しただけで 復号処理は変換ディクショナリを作って 1 文字ずつ置き換えてるだけです

それと 考えてみたら import をしています
__main__ の判定とかないので -m で実行しなくても print が実行されています
まぁこれを import する時点で出力するしかなくて文字列として取得したいことはなさそうですし

もし 文字列として取得したいなら this の d と s を使ってこうできます

>>> zp_str = "".join([this.d.get(c, c) for c in this.s])
>>> zp_str[0:50]
'The Zen of Python, by Tim Peters\n\nBeautiful is bet'