How To Use Dunder Methods In Python Tutorial (Magic Methods)

  Рет қаралды 12,290

Indently

Indently

Күн бұрын

In this video I will be teaching you all the essentials you need to know when it comes to using dunder methods in Python.
▶ Become job-ready with Python:
www.indently.io
▶ Follow me on Instagram:
/ indentlyreels
00:00 Introduction to dunder methods
00:34 What do we use dunder methods for?
01:34 How to use a dunder method
03:00 What about other dunder methods?
04:33 Exploring the dunder methods
05:53 Do you have any thoughts on dunder methods? 06:29 That’s all for this time folks!

Пікірлер: 27
@Exvixcity
@Exvixcity 5 ай бұрын
def __enter__(self) and def __exit__(self) are really useful too. It allows you to use the with() keyword with your class. __enter__ defines what happens as soon as the line with the "with" keyword runs. You don't need to do anything special here, just make sure you "return self" __exit___ defines what happens as soon as the scope changes or there's no more code left to run. Just clean up and/or close files, active connections.etc
@MeHdi.fz28
@MeHdi.fz28 5 ай бұрын
It's called context manager, like open function
@Lord_Shan
@Lord_Shan 5 ай бұрын
Thanks for such short but highly informative videos
@fusebox9725
@fusebox9725 5 ай бұрын
I finally understand dunder methods. Thanks sooo much ❤
@Naruto.Hinata-clips
@Naruto.Hinata-clips 5 ай бұрын
I am very happy when I see your videos ❤
@loverboykimi
@loverboykimi 5 ай бұрын
This is Gold!
@ufukyarsan2149
@ufukyarsan2149 5 ай бұрын
nice, thanks
@gauravsoni4025
@gauravsoni4025 5 ай бұрын
Flet tutorials plz.. I really enjoy by learning it.
@kumaranb8702
@kumaranb8702 5 ай бұрын
Very nice 🙂❤
@rishiraj2548
@rishiraj2548 5 ай бұрын
🎉
@miguelvasquez9849
@miguelvasquez9849 5 ай бұрын
where can i find all the dunder methods? i cant find them in python docs
@marcelo7302
@marcelo7302 3 ай бұрын
I have the same problem, guess that's why they're magic 😂
@krzysiekkrzysiek9059
@krzysiekkrzysiek9059 5 ай бұрын
Cool 👍
@JopeliH
@JopeliH 5 ай бұрын
What font are you using? The characters combining into one arrow seems interesting
@Nicfallenangel
@Nicfallenangel 5 ай бұрын
I'm not sure exactly what font he is using, but it's probably a Nerd Font with "font ligatures" turned on. Ligatures is the feature that combines the characters. I use a font called FiraCode that has support for ligatures and it looks weird now any time I'm using some other system that doesn't support them.
@JakkeJakobsen
@JakkeJakobsen 3 ай бұрын
​@@Nicfallenangel Works in other IDEs? Like VSCode?
@danielagu4309
@danielagu4309 5 ай бұрын
I want to learn python programming language please 🙏 can you teach me
@kingfunny4821
@kingfunny4821 5 ай бұрын
If I have an application made in Python and a copy is given to a person in America and a copy is given to a person in Italy, how can I make the two people exchange messages with each other? Can you give information about this?
@Indently
@Indently 5 ай бұрын
If you're talking about creating a chat app, you need to look into writing code that runs a server that both of you can connect to. One of you will have to run the server, but then anyone can connect to it.
@kingfunny4821
@kingfunny4821 5 ай бұрын
Has this been explained previously on your channel?
@celestialowl8865
@celestialowl8865 5 ай бұрын
Maybe consider coveirng infix operators. Not super useful at least as far as clean code goes, but certainly a neat trick
@Indently
@Indently 5 ай бұрын
Thanks for the suggestion, looks super interesting as a trick ahaha, probably will be one of the next shorts
@devabdul
@devabdul 5 ай бұрын
Can we create user magic method?
@Y0annSA
@Y0annSA 5 ай бұрын
You technically can define a method named __banana__​ (for example), Python doesn't forbid it, but it wouldn't be "magic". Standard dunder methods are methods that Python automatically calls under specific situations. Since Python wasn't programmed to use __banana__​ in any way, it wouldn't have any effect unless you call it explicitly. It's just a normal method with bad naming convention. You would have to fork and develop your own version of Python to create a new magic method
@Indently
@Indently 5 ай бұрын
I think we should start a petition though to make __banana__ a world standard by Python 3.15
@Y0annSA
@Y0annSA 5 ай бұрын
@@Indently I just found out that writing dunder methods in youtube comments is really annoying since it really wants to make them italic (and removing a pair of underscores in the process). But I found a little cheat by writing a zero-width space immediately after (still not very convenient to find and copy one) (or you could add an extra pair of underscores and accept that it's italic)
@Indently
@Indently 5 ай бұрын
But I really like the single underscore Italic version, because as Python devs we all know what we were trying to do xD
I Didn't Know Python Allowed THIS Syntax
9:19
Indently
Рет қаралды 47 М.
5 Useful Dunder Methods In Python
16:10
Indently
Рет қаралды 48 М.
CAN YOU HELP ME? (ROAD TO 100 MLN!) #shorts
00:26
PANDA BOI
Рет қаралды 35 МЛН
100❤️
00:19
Nonomen ノノメン
Рет қаралды 35 МЛН
BRUSH ONE’S TEETH WITH A CARDBOARD TOOTHBRUSH!#asmr
00:35
HAYATAKU はやたく
Рет қаралды 7 МЛН
10 Ways You Can Use "_" In Python (Do you know ALL of them?)
9:56
Python Classes Tutorial #5 | Advanced Concepts
10:08
Aikonic
Рет қаралды 4,1 М.
5 Useful Python Decorators (ft. Carberra)
14:34
Indently
Рет қаралды 82 М.
Python: A Quick Guide To Type Annotations (ft. Mypy)
11:25
Indently
Рет қаралды 25 М.
5 Really Cool Python Functions
19:58
Indently
Рет қаралды 31 М.
5 Uncommon Python Features I Love
15:09
Indently
Рет қаралды 123 М.
5 Tips To Write Better Python Functions
15:59
Indently
Рет қаралды 79 М.
ALL 11 Dictionary Methods In Python EXPLAINED
9:26
Indently
Рет қаралды 47 М.