Skip to content
← Back to Community
Python Easter Egg
Profile icon
[deleted]

Not many people actually know about this easter egg in python.

By typing import this into either a python interpreter or a python shell you can be presented with Tim Peters' 20 aphorisms Guiding principles for writing Python, however, he only wrote down 19, why? I don't know.

Anyway, I'll leave you with that, if you know of any more easter eggs, leave a comment with it!

Have a great Day!

Voters
Profile icon
IrishGarnett
Profile icon
Kizuo
Profile icon
davidyu9
Profile icon
AustinZhang1
Profile icon
44zdawg
Profile icon
GaryShauman
Profile icon
NathanCaputo
Profile icon
marrcoding
Profile icon
AshtonCanaday
Profile icon
LOLLIPOP06
Comments
hotnewtop
Profile icon
Highwayman

Try
from __future__ import braces

Profile icon
tobyyhsieh

@Highwayman nice lol

Profile icon
Highwayman

@tobyyhsieh thanks!

I hadn’t noticed it had so many upvotes cool.

Profile icon
[deleted]

@Highwayman
import this
import antigravity
import __hello__

>>> import this ... >>> love = this >>> this is love True >>> love is True False >>> love is False False >>> love is not True or False True >>> love is not True or False; love is love # FML True

the this.py moudule is:

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]))
>>> infinity = float('infinity') >>> hash(infinity) 314159 >>> hash(float('-inf'))
>>> from antigravity import geohash >>> # Your location, a date and that date's (or most recent) DJIA opening. >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68') 37.857713 -122.544543
>>> from math import pi >>> π = pi >>> area = π * r**2 >>> résumé = 'knows Python' >>> 'Python' in résumé True
Profile icon
Highwayman

@TaylorLiang

'Python' in résumé

my favorite that was good lol.

Profile icon
[deleted]

@TaylorLiang Lol, thanks for those.

Profile icon
[deleted]

@Highwayman Nice one

Profile icon
SixBeeps

@TaylorLiang

import antigravity

is that an xkcd reference? lol

EDIT: It definitely is

Profile icon
[deleted]

@niorg2606 I think so

Profile icon
[deleted]

@niorg2606 if your run it on your own computer (like the python interpriter) it opens up that comic

Profile icon
AphixDev
Profile icon
[deleted]

nice
Screenshot 2020-01-13 at 08.36.58

Profile icon
elburg

nice

Profile icon
AtticusKuhn

This is my personal favorite thing to do in my limited knowledge of python

Profile icon
Flux3on

Never have I enjoyed 11 bytes of code more.

Profile icon
Highwayman

I had forgotten about that..

Profile icon
RobertFurr

from future import braces

Profile icon
Slade01

egg

Profile icon
KhoiXuanXuan

import antigravity will do some stuff.

Profile icon
MrEconomical

cool
tim peters is E

Profile icon
PowerCoder

Oh! I've heard about this. Cool! (I never actually tried it.)

Profile icon
PVWalsh

waaaaaaaaaaaa????????????????????

Profile icon
nathancoder

you can also use
import that

Profile icon
merrillUwU

cool

Profile icon
eaz

ah yes, the fabled zen of python
the secret 20th part is xkcd.com, because import antigravity makes xkcd canonically part of the python stdlib

Profile icon
[deleted]

@eaz Ah, thanks for that, I never knew that.

Profile icon
AugnivMitra

Also, typing import that You can see The Anti-Zen of Python

Profile icon
leFrank

import that typed in adds more poems

Profile icon
ChoppaFan2007

wow this sure is a cool post! i love it! but i love my choppa more

Profile icon
[deleted]

@ChoppaFan2007 Ok, Thanks!

Profile icon
MilesMiller

bruh

Profile icon
diediediedie
Profile icon
ThePhoenixfish

Import that also worked to give the ant zen!
:D

Profile icon
Me54321

Uh...

Profile icon
JoelMenezes

@JacksonCowie have you tried import that ?

Profile icon
[deleted]

@JoelMenezes Yeah That one is good as well!

Profile icon
MartiCliment

it seems to also work with:
impot that

--or, in CMD:

pip install that
import that

Profile icon
diediediedie

@MartiCliment I hate FACTS