For the code to generate `zen of python'.

Thomas Jollans tjol at tjol.eu
Wed Aug 7 09:29:00 EDT 2019


On 07/08/2019 15.11, Hongyi Zhao wrote:
> Hi here,
>
> I noticed that the `zen of python' is generated by the following code:
>
> 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]))
>
>
> But the above code is not so easy for me to figure out.  Could someone 
> please give me some explanations on it?
>
> Regards


This code
[https://github.com/python/cpython/blob/master/Lib/this.py#L23] doesn’t
‘generate’ the Zen of Python, really. It just decrypts it. The Zen of
Python is hidden just above those lines.

Abj gur dhrfgvba vf: pna lbh svther bhg gur plcure?




More information about the Python-list mailing list