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

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!

Пікірлер: 29

  • @Exvixcity
    @Exvixcity7 ай бұрын

    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

    7 ай бұрын

    It's called context manager, like open function

  • @anonymous.youtuber
    @anonymous.youtuber2 күн бұрын

    Great ! I had heard of dundermethods but I had no idea where the name came from. Thanks !

  • @Lord_Shan
    @Lord_Shan7 ай бұрын

    Thanks for such short but highly informative videos

  • @fusebox9725
    @fusebox97257 ай бұрын

    I finally understand dunder methods. Thanks sooo much ❤

  • @Naruto.Hinata-clips
    @Naruto.Hinata-clips7 ай бұрын

    I am very happy when I see your videos ❤

  • @loverboykimi
    @loverboykimi7 ай бұрын

    This is Gold!

  • @ufukyarsan2149
    @ufukyarsan21497 ай бұрын

    nice, thanks

  • @gauravsoni4025
    @gauravsoni40257 ай бұрын

    Flet tutorials plz.. I really enjoy by learning it.

  • @krzysiekkrzysiek9059
    @krzysiekkrzysiek90597 ай бұрын

    Cool 👍

  • @kumaranb8702
    @kumaranb87027 ай бұрын

    Very nice 🙂❤

  • @rishiraj2548

    @rishiraj2548

    7 ай бұрын

    🎉

  • @Nikita-ln8db
    @Nikita-ln8db8 күн бұрын

    need your pycharm setup

  • @miguelvasquez9849
    @miguelvasquez98497 ай бұрын

    where can i find all the dunder methods? i cant find them in python docs

  • @marcelo7302

    @marcelo7302

    5 ай бұрын

    I have the same problem, guess that's why they're magic 😂

  • @JopeliH
    @JopeliH7 ай бұрын

    What font are you using? The characters combining into one arrow seems interesting

  • @Nicfallenangel

    @Nicfallenangel

    7 ай бұрын

    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

    5 ай бұрын

    ​@@Nicfallenangel Works in other IDEs? Like VSCode?

  • @danielagu4309
    @danielagu43097 ай бұрын

    I want to learn python programming language please 🙏 can you teach me

  • @celestialowl8865
    @celestialowl88657 ай бұрын

    Maybe consider coveirng infix operators. Not super useful at least as far as clean code goes, but certainly a neat trick

  • @Indently

    @Indently

    7 ай бұрын

    Thanks for the suggestion, looks super interesting as a trick ahaha, probably will be one of the next shorts

  • @kingfunny4821
    @kingfunny48217 ай бұрын

    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

    7 ай бұрын

    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

    7 ай бұрын

    Has this been explained previously on your channel?

  • @devabdul
    @devabdul7 ай бұрын

    Can we create user magic method?

  • @Y0annSA

    @Y0annSA

    7 ай бұрын

    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

    7 ай бұрын

    I think we should start a petition though to make __banana__ a world standard by Python 3.15

  • @Y0annSA

    @Y0annSA

    7 ай бұрын

    @@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

    7 ай бұрын

    But I really like the single underscore Italic version, because as Python devs we all know what we were trying to do xD