5 Fun Python Easter Eggs

  Рет қаралды 33,698

Indently

Indently

Күн бұрын

Here are 5 fun Python easter eggs that you should know about if you love Python.
▶ Become job-ready with Python:
www.indently.io
▶ Follow me on Instagram:
/ indentlyreels
00:00 Learning Python made simple
00:05 Intro
00:23 Easter egg #1
01:07 Easter egg #2
01:43 Secret challenge
02:22 Easter egg #3
04:16 Easter egg #4
04:46 Easter egg #5
05:08 Why is this here?
06:10 Summing it up

Пікірлер: 73
@smergibblegibberish
@smergibblegibberish 18 күн бұрын
You can see the source code for the `this' module at `this.__file__'. It has purposefully bad code to demonstrate what not to do. That's part of the poetry that a lot of people miss.
@joaozin003
@joaozin003 16 күн бұрын
And it contains the challenge solution
@Hylasavignyi
@Hylasavignyi 15 күн бұрын
Just by looks it seems to be Ceasar Cipher. The decoder table is provided in the same module. Here is a one-liner to recover the text ''.join([this.d.get(c, c) for c in this.s])
@Un_revealing
@Un_revealing 21 күн бұрын
THE braces one made my day
@replikvltyoutube3727
@replikvltyoutube3727 21 күн бұрын
If only it worked 😤
@ahmoin
@ahmoin 20 күн бұрын
it ruined mine
@smergibblegibberish
@smergibblegibberish 18 күн бұрын
@@replikvltyoutube3727 It worked back in 2.5.
@notlogic.the.second
@notlogic.the.second 17 күн бұрын
same😂
@granitium
@granitium 10 күн бұрын
I kinda didn't get it
@ego-lay_atman-bay
@ego-lay_atman-bay 21 күн бұрын
I had no idea python HAD easter eggs. I'm so glad I watched your video, because I learned something new.
@aeghohloechu5022
@aeghohloechu5022 21 күн бұрын
5:48 geohasing is another one of xkcd comics which is like a random location generator you can go hiking to.
@Joulespersecond
@Joulespersecond 21 күн бұрын
It's a play on words with GeoCaching and hashing. The algorithm name is also a joke, because Randall Munroe is the creator of xkcd.
@FishDisks
@FishDisks 21 күн бұрын
And Munroe is the surname of the creator of xkcd, Randall Munroe, and as he invented the algorithm in the geohashing comic it's naturally named after him.
@TheFreaxTux
@TheFreaxTux 21 күн бұрын
426th xkcd
@SilverSuperGamer
@SilverSuperGamer 17 күн бұрын
Me: bracing myself for him typing var: str = "..."
@russtest
@russtest 19 күн бұрын
The first Easter egg is an example script for the Freeze utility that comes with Python. The instructions for Freeze uses the `hello.py` file so you can test it out. Per the Github repo for Python: ``` Freeze make it possible to ship arbitrary Python programs to people who don't have Python. The shipped file (called a "frozen" version of your Python program) is an executable, so this only works if your platform is compatible with that on the receiving end (this is usually a matter of having the same major operating system revision and CPU type). The shipped file contains a Python interpreter and large portions of the Python run-time. Some measures have been taken to avoid linking unneeded modules, but the resulting binary is usually not small. ``` Originally the Hello script would print `Hello World` just by importing the module. Starting in Python 3.11 it uses the `main()` function. I love these Easter Egg videos. I end up falling down a rabbit hole and learning a lot more than just the Easter egg.
@AsgerJon
@AsgerJon 21 күн бұрын
__hello__ was added in python 3.11
@zaicol850
@zaicol850 16 күн бұрын
Not long ago
@thefanboy3285
@thefanboy3285 21 күн бұрын
1. Fellas, I need your help to conclude a debate once and for all : the correct way to print "Hello World!" is without a comma? or "Hello, World!" with a comma ? 2. I did not know any of these. I'm kinda new to python. 3. I'm gonna mess with an entire codebase by importin braces everywhere lmaooo
@osnofla13ify
@osnofla13ify 21 күн бұрын
No comma, it's part of the fun.
@Indently
@Indently 21 күн бұрын
I think what you meant was: No comma it's part of the fun.
@callbettersaul
@callbettersaul 21 күн бұрын
Neither is correct, because "world" isn't someone's name (to my knowledge :D) and should be lowercased. Other than that, I'm pretty sure, that with comma is grammatically correct, but almost no one uses it there.
@ahmoin
@ahmoin 20 күн бұрын
@@callbettersaul _Hello World_ is a title tho
@haipingcao2212
@haipingcao2212 17 күн бұрын
​@@ahmoinno
@davidagnew8465
@davidagnew8465 20 күн бұрын
Python provides another module, *codecs*, that decodes this.s: Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32 import this ...[poem elided].... import codecs as c print(c.decode(this.s, 'rot13')) ...[decoded poem elided]... So, we see that rot13 is one of the many batteries included in Python.
@david-komi8
@david-komi8 17 күн бұрын
You can pretty much do the same thing with instance and static methods without importing anything; print(this.s.translate(str.maketrans(this.d))). But it's good to know anyways :)
@mikejohnston9113
@mikejohnston9113 20 күн бұрын
These are great! thanks
@ERRORRubiksZeraBrand
@ERRORRubiksZeraBrand 21 күн бұрын
1:48 i have translated the message, it's just caesar chiper. it returns: 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! IT'S THE SAME THING
@1vader
@1vader 20 күн бұрын
Yeah, iirc the cipher text is what is stored in thr source code so that the easter egg is somewhat hidden. But it already decodes it for you when you run it. So the d and s aren't additional easter eggs, they are implementation details.
@dipeshsamrawat7957
@dipeshsamrawat7957 20 күн бұрын
Broh, may I please know which software do you use to create your very good Thumbnails and icons??
@SolathPrime
@SolathPrime 21 күн бұрын
[ 2:13 ]: this is actually easy it's just the alphabet shifted and can be solved vary easily
@shikanokonokokoshitantan
@shikanokonokokoshitantan 21 күн бұрын
You dont need to do that since the dictionary to translate it already exists in the module, "this.d", and the raw string is, "this.s"
@SolathPrime
@SolathPrime 21 күн бұрын
@@shikanokonokokoshitantan that dictionary is actually generated on runtime meaning it was not hardcoded
@shikanokonokokoshitantan
@shikanokonokokoshitantan 21 күн бұрын
@@SolathPrime Then that means that the module hardcoded, ofc I am not saying that value is defined WITH the module I am saying that its defined WITH the STRING that is PRINTED when you import this, using the dictionary you can decode this.s using a simole for loop or using a list comprehension.
@david-komi8
@david-komi8 17 күн бұрын
Stop fighting, it's as simple as writing "print(this.s.translate(str.maketrans(this.d)))"
@david-komi8
@david-komi8 17 күн бұрын
And also, I'd like to mention that the method used to rotate the alphabet is ROT13, which rotates the alphabet 13 places.
@paweleke123
@paweleke123 18 күн бұрын
instead of _hello_ why not just use constant for the string?
@darlinginc.3653
@darlinginc.3653 17 күн бұрын
damn thanks for telling me how i can print hello world! i was actually struggling for a bit with it had to type it out 100x times and misspelled it a lot
@JinYuanz11
@JinYuanz11 21 күн бұрын
Thank you
@leightaylor8069
@leightaylor8069 19 күн бұрын
What is a datedow, and why is it needed?
@tema5002
@tema5002 13 күн бұрын
lmao i have modified built-in json library and call it antigrav (dont question why) and uploaded to pypi i discovered antigravity is a thing only now now i feel like i made a cheap copy
@EdKolis
@EdKolis 4 күн бұрын
That antigravity thing reminded me of a video I just watched about MS Office macro viruses. Who thought it was a good idea to give a programming language the ability to open a browser window?
@Shuflduf
@Shuflduf 17 күн бұрын
what IDE/text editor is this?
@ramprasathmk
@ramprasathmk 15 күн бұрын
PyCharm IDE for Python Developers
@DrDeuteron
@DrDeuteron 21 күн бұрын
how did I not know any of these? (other than this, everyone knows that)
@shikanokonokokoshitantan
@shikanokonokokoshitantan 21 күн бұрын
Eyy second again!
@user-hr8rc1of3x
@user-hr8rc1of3x 12 күн бұрын
Geohashing is reference to another xkcd webcomic
@Asparion
@Asparion 13 сағат бұрын
c# coders would flip at the braces thing.. oh wait, don't i know a bit of c#- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@xxlarrytfvwxx9531
@xxlarrytfvwxx9531 15 күн бұрын
1:28 I have a shortcut to this on my desktop.
@comandanteej
@comandanteej 21 күн бұрын
print(''.join([this.d.get(x,x) for x in this.s])) -- is there a more pythonic way to do it?
@denizsincar29
@denizsincar29 21 күн бұрын
yes there is. ''.join(map(this.d.get, this.s, this.s)
@EvanED
@EvanED 21 күн бұрын
I will leave it to you to decide about the comprehension versus map, but at least remove the explicit list comprehension if you stick with something like that. You can remove both square braces, and unless I am missing something it will still work. What you would doing instead is called a generator expression. Generally, you need to use parentheses around a generator expression, but there are sometimes when you can omit them because they would just be duplicative. Duplicative. Passing a generator expression as a single parameter to a function is one such time.
@avxqt966
@avxqt966 21 күн бұрын
also import this import codecs print(codecs.decode(this.s, 'rot13'))
@Indently
@Indently 21 күн бұрын
That's interesting, I didn't know it was encoded using ROT13!
@DDvargas123
@DDvargas123 21 күн бұрын
`print(this.s.translate(str.maketrans(this.d)))`
@captheobbyist6434
@captheobbyist6434 9 күн бұрын
the "this.d" is the decoding table for "this.s" inline solution: print(''.join([this.d[i] if i in this.d else i for i in this.s])) i loved solving this
@contemporarychemists
@contemporarychemists 21 күн бұрын
Huh all good but the first one Now we need help to print hello world 😢
@camiloamadio
@camiloamadio 20 күн бұрын
Las Malvinas son argentinas!!!
@theuntitledgoose
@theuntitledgoose 21 күн бұрын
early
@Etchacritic
@Etchacritic 21 күн бұрын
Almost decodes the this.s message correctly. The only problem is that when you import this, you immediately get the text, so when you run this on the command line, it prints it out twice. python -c 'from this import d, s; j = d; j[" "] = " "; j[" "] = " "; print("".join([j[x] for x in list(s) if x.isalpha() or x == " " or x == " "]))'
@david-komi8
@david-komi8 17 күн бұрын
Is much better to use this.s.translate and str.maketrans like this; import this print(this.s.translate(str.maketrans(this.d))) You can make it shorter by importing s and d directly, but the point is that you can use the dictionary and the translate method to do the work.
5 Really Cool Python Functions
19:58
Indently
Рет қаралды 38 М.
5 Cool Python One-Liners
12:23
Indently
Рет қаралды 22 М.
Pray For Palestine 😢🇵🇸|
00:23
Ak Ultra
Рет қаралды 35 МЛН
ПООСТЕРЕГИСЬ🙊🙊🙊
00:39
Chapitosiki
Рет қаралды 32 МЛН
New Gadgets! Bycycle 4.0 🚲 #shorts
00:14
BongBee Family
Рет қаралды 13 МЛН
5 Uncommon Python Features I Love
15:09
Indently
Рет қаралды 127 М.
Python: A Quick Guide To Type Annotations (ft. Mypy)
11:25
Indently
Рет қаралды 26 М.
How FastAPI Handles Requests Behind the Scenes
5:09
Code Collider
Рет қаралды 9 М.
5 Tips To Write Better Python Functions
15:59
Indently
Рет қаралды 85 М.
8 Design Patterns | Prime Reacts
22:10
ThePrimeTime
Рет қаралды 381 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,7 МЛН
I Made a Neural Network with just Redstone!
17:23
mattbatwings
Рет қаралды 439 М.
5 Useful Python Decorators (ft. Carberra)
14:34
Indently
Рет қаралды 84 М.
Is "finally" Useless In Python?
7:02
Indently
Рет қаралды 49 М.