Python OOP Tutorial 5: Special (Magic/Dunder) Methods

In this Python Object-Oriented Tutorial, we will be learning about special methods. These are also called magic or dunder methods. These methods allow us to emulate built-in types or implement operator overloading. These can be extremely powerful if used correctly. We will start by writing a few special methods of our own and then look at how some of them are used in the Standard Library. Let's get started.
Python Docs: docs.python.org/3/reference/d...
Python OOP 1 - Classes and Instances - • Python OOP Tutorial 1:...
Python OOP 2 - Class Variables - • Python OOP Tutorial 2:...
Python OOP 3 - Classmethods and Staticmethods - • Python OOP Tutorial 3:...
Python OOP 4 - Inheritance - • Python OOP Tutorial 4:...
Python OOP 5 - Special (Magic/Dunder) Methods - • Python OOP Tutorial 5:...
Python OOP 6 - Property Decorators - • Python OOP Tutorial 6:...
The code from this video can be found at:
github.com/CoreyMSchafer/code...
✅ Support My Channel Through Patreon:
/ coreyms
✅ Become a Channel Member:
/ @coreyms
✅ One-Time Contribution Through PayPal:
goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - coreyms.com/
My Second Channel - / coreymschafer
Facebook - / coreymschafer
Twitter - / coreymschafer
Instagram - / coreymschafer
#Python

Пікірлер: 528

  • @kickbuttowsk2i
    @kickbuttowsk2i4 жыл бұрын

    the amount of 'aha' moment in this series is unimaginable.

  • @plato5138

    @plato5138

    3 жыл бұрын

    @Tomas Alvaro Stop with those spam comments

  • @sndselecta

    @sndselecta

    3 жыл бұрын

    Hilarious.

  • @MTSNSri

    @MTSNSri

    2 жыл бұрын

    @@sndselecta L

  • @timothywyatt722

    @timothywyatt722

    2 жыл бұрын

    Sorry to be off topic but does any of you know of a tool to log back into an Instagram account? I stupidly lost the password. I love any tips you can give me

  • @randallbilly1122

    @randallbilly1122

    2 жыл бұрын

    @Timothy Wyatt instablaster =)

  • @ryanthornton3556
    @ryanthornton3556 Жыл бұрын

    6 years later and this is still invaluable

  • @nasifshah5691

    @nasifshah5691

    3 ай бұрын

    7*

  • @nickbrigham8546

    @nickbrigham8546

    12 күн бұрын

    @@nasifshah5691 agreed.

  • @garydunken7934
    @garydunken79347 жыл бұрын

    What I like about your videos is that there's no emming, erring or dribbling of words. Well planned and execution of tutorial; nice clear, crisp flow and sticking to point really well. Excellent. Please keep them coming.

  • @effuseakay

    @effuseakay

    5 жыл бұрын

    I agree. I can see you put a lot of work into planning your videos. There is barely any typos, everything is crystal clear with examples, etc. Seriously thank you so much!

  • @madagascar9407

    @madagascar9407

    4 жыл бұрын

    @@effuseakay do you think he is cutting his videos and looking up what to say next? It seems like he does everything out of memory spontaneously, but perfectly fine

  • @nicop175

    @nicop175

    4 жыл бұрын

    That's why Corey puts a video per month or so, buuut they are so good.

  • @ildar_eto_ya

    @ildar_eto_ya

    4 жыл бұрын

    Aaaaaahhhyeeeeeeeaaahhhhh!

  • @rajaspydey

    @rajaspydey

    3 жыл бұрын

    Just like CS50. PLAIN & SIMPLE

  • @andresvodopivec5950
    @andresvodopivec59505 жыл бұрын

    Normally I never comment but really have to say tow things: thanks so much for the tutorial and by far the best and flawless (material and speech) python tutorial ever seen. Nice talent Corey!

  • @coreyms

    @coreyms

    5 жыл бұрын

    Thanks!

  • @mosesmbabaali9381

    @mosesmbabaali9381

    4 жыл бұрын

    @@coreyms your a rock star!!! Good stuff.

  • @christianfuchs9405
    @christianfuchs94056 жыл бұрын

    best python tutorials on youtube. period.

  • @nelsongg347
    @nelsongg3475 жыл бұрын

    I started with Python from two weeks ago I come from Php and Java so I have a good understanding of Classes and Objects, but I have to tell you that the way you present every topic is magistral. Thank you very much for your flawless tutorial. And the extra for me is that your tutorials are also an English class.

  • @betulabendula6270
    @betulabendula62707 жыл бұрын

    These OOP tutorials are worth gold! They make difficult subject to look so easy!

  • @ankurjain5286
    @ankurjain52868 жыл бұрын

    @Corey - You are an excellent teacher and know exactly how to tell/teach about any topic. I have seen all of your videos and learnt a lot by watching these tutorials. Can you please upload some videos on some of the python concepts like - Multiprocessing, Design patterns, MetaClasses as well.

  • @xiaolu7988
    @xiaolu79885 жыл бұрын

    My favorite part of your tutorials is that you give a great great example come from standard or well-known library to show us what those skills are used in dealing with real-world programming issues. A hundred thumb-ups!

  • @Mrjarnould
    @Mrjarnould8 жыл бұрын

    Keep up the Python OOP tutorial, they're great!

  • @seymoreclearly
    @seymoreclearly5 жыл бұрын

    So clear, concise, and precise. Best Python tutorials I have yet come across on KZread

  • @L0V3V4MP1R3
    @L0V3V4MP1R34 жыл бұрын

    I had an ungodly amount of trouble understanding OOP in general and I think that in the middle of many other tutorials, yours were the first that I could finally understand and keep up with without getting lost halfway through the lecture. Thank you so much, keep the wonderful content coming! ♥

  • @Sjongleringsmannen
    @Sjongleringsmannen5 жыл бұрын

    Great series of tutorials on OOP! I really love them. Very clear and with a speedy pace!

  • @GodsNode
    @GodsNode6 жыл бұрын

    You are like the Khan Academy of Python code. Great explanations and examples.

  • @bobboulden
    @bobboulden3 жыл бұрын

    These videos are such a lifesaver for me. Gives me actual understanding instead of me just stumbling along, not knowing what I'm really doing.

  • @calistosmindfulsoundsofnature
    @calistosmindfulsoundsofnature Жыл бұрын

    This video specifically has opened some doors for me in understanding classes and special methods used inside algorithms. Always learning something new each day on my coding journey!!! It never stops and I love it!!

  • @navroze92
    @navroze925 жыл бұрын

    You Sir need a million subs just for teaching this one episode. So clean and precise!! Thank you for the work you put in we really appreciate it.

  • @baterickpatman
    @baterickpatman Жыл бұрын

    DUDE you're the fkn MAN.. been following this series and everything about your presentation is SO great. Thank you so much :) I will be donating

  • @NicholasKimble
    @NicholasKimble4 жыл бұрын

    Who is down voting your videos? You are a master and clearly demonstrate your command of this language by how easily you simplify these concepts for me. Thank you, good sir!

  • @Caffeinegoesinface
    @Caffeinegoesinface7 жыл бұрын

    you kick ass! This has been invaluable to a university project I'm working on at the moment Thanks!

  • @sueholder703
    @sueholder7034 жыл бұрын

    I have just spent the day going through this series as I am studying and needed to understand this concept better. Your series has been superb and I'm so thankful. Thank you for sharing your extensive knowledge in a way that is clear and easy to understand. When I am working I will support through Patreon to pay it forward so you keep on making them. I am going to watch many more of your videos from here on, I am sure.

  • @coreyms

    @coreyms

    4 жыл бұрын

    Thanks!

  • @tanmayag97
    @tanmayag974 жыл бұрын

    Probably the best tutorial of OOPS in the world. 👌

  • @pipertripp
    @pipertripp5 жыл бұрын

    This was a great video. I've been curious about operator overrides in python for a little bit. Blundered into the answers in this video and within 30 minutes had a working Vector class from scratch that handles all the basics. Thanks much for the really excellent content on your channel. I have to echo the other folks who point out how well you present the information. Well done!

  • @antonkamnev2067
    @antonkamnev20673 ай бұрын

    My eyes have finally opened to so many things in python! Thanks!

  • @cipher6042
    @cipher60424 жыл бұрын

    Ive been watching your videos and they have already helped me in my Job as a Site Reliability Engineer to write better python code, you have also helped me understand concepts that I haven't truly understood for the years Ive been in software development. Thank you for your great explanations. You definitely are making a great difference in peoples lives. Keep on Keeping on!

  • @artmcclure637
    @artmcclure6377 жыл бұрын

    Finally, I understand Classes. Thank you!

  • @returnedfaith7254
    @returnedfaith72546 жыл бұрын

    Your tutorials take into depth, which is something others of same kind never did. I'm lucky finding you.

  • @gershondevadason4656
    @gershondevadason46562 жыл бұрын

    Exactly what I needed. Clear, comprehensive and great examples! Nice work man!

  • @KnightShade227
    @KnightShade2274 жыл бұрын

    been playing around with code trying to learn and I've just watched the four previous videos on classes, they're the one thing I've had issues with during my year of coding so far, and your videos helped me figure out how to incorporate them into my lil pygame, so thanks! good job breaking them down and explaining each part of them! I'll finish this one tomorrow morning 😁

  • @CharlesDibsdale
    @CharlesDibsdale7 жыл бұрын

    Corey, thanks for your tutorials, you are clear to the point, and avoid waffle. The dunder methods are helping me debug my app much more efficiently.

  • @mrmabb123
    @mrmabb1235 жыл бұрын

    I finally feel I have a complete picture on Python basics despite already learning it for 4 months. Thanks.

  • @raghavnegi713

    @raghavnegi713

    3 жыл бұрын

    Same with me

  • @user-mj1lu4cl1j
    @user-mj1lu4cl1j Жыл бұрын

    If I ever had a any doubts on python I would look no further than your playlist. I recommend people to refer your videos first because it's no time-wasting around and just pure content.. Plus hat's off to your clear and concise language with in depth knowledge and a perfect pace while explaining.. Keep up the great work.. You are flamboyant God bless you Corey.. :)

  • @JeremyFisher
    @JeremyFisher4 жыл бұрын

    You don't know how much we appreciate your work here Corey, best way of teaching and a good soul, we love you.

  • @billcallahan218
    @billcallahan2188 ай бұрын

    Boy am I glad I found this tutorial. II was over my head on OOP. Can't believe how much I've learned in just 5 videos. Right on Corey!!

  • @xiaolu7988
    @xiaolu79885 жыл бұрын

    Really clear and insightful explanations. Love it!

  • @kamolusmonov6540
    @kamolusmonov65405 жыл бұрын

    First, I must say huge thanks ) I'm so impressed by your videos and have been learning through them, and I watch your channel pretty much every day.

  • @23TrevorE
    @23TrevorE7 жыл бұрын

    Yet another brilliant tutorial, Corey. Many thanks.

  • @user-qu2zc4rp9v
    @user-qu2zc4rp9v6 жыл бұрын

    Questions are sophisticated but your answers are simple. Great respect and hundreds years of happiness!

  • @charlesfoster2644
    @charlesfoster26446 жыл бұрын

    HUGE "ah-hah" moments going on here for me anyway. THANK YOU SIR!!!!

  • @anonymous_anonymity
    @anonymous_anonymity5 жыл бұрын

    One of the best python tutorials I’ve ever seen

  • @Asparuh.Emilov
    @Asparuh.Emilov Жыл бұрын

    You are by far, the most absolute best Python Teacher out there! Thank you soooooo much for being the best! ♥️♥️♥️♥️♥️

  • @dozieu8539
    @dozieu85393 жыл бұрын

    Communication is so human and yet so otherworldy, thanks Corey

  • @kamalakannank3370
    @kamalakannank33702 жыл бұрын

    One of best explanation learning video to understand class and object

  • @antonisvenianakis1047
    @antonisvenianakis10472 жыл бұрын

    Thank you. Everyone is right here at the comments saying how good your videos are. I can only be grateful

  • @christydiness6200
    @christydiness62005 жыл бұрын

    That's a crystal clear explanation Corey....Really helpful

  • @yahyakenoussi577
    @yahyakenoussi5773 жыл бұрын

    No explanation can be better than what you did during the whole playlist. Thanks.

  • @sreekanththota2200
    @sreekanththota22004 жыл бұрын

    Mr.Corey, You did magic with OOP....really...it's very informative....THE BEST PYTHON series..... I never Watched........Thanks...a lot...& also do more on Machine learning and Datascience with Python

  • @jamessmith732
    @jamessmith7324 жыл бұрын

    Exceptionally well, such organized Tutorials are intellectual assets that are really devoted free to learner community.

  • @dpynsnyl
    @dpynsnyl4 жыл бұрын

    I am an avid follower of your tutorials from the day KZread recommend me your ___name___ video. I loved it and got hooked to your style of teaching. Today when I got stuck at a problem in Hackerrank, I *Coreyed* the problem (fancy term for Googled when it comes to Python) and voila there it is; the video I wanted! Viel Danke Corey!

  • @dustinhxc
    @dustinhxc Жыл бұрын

    Wow changing what it displays is priceless. Thank you for the Dunder explanation!

  • @djkunsal
    @djkunsal5 жыл бұрын

    Thank you for this awesome set of tutorials. I came in from the PHP world and your explanations gave me a headsup to Python OOP

  • @Khushpich
    @Khushpich4 жыл бұрын

    Great tutorial, straight to the point. Thanks Corey!

  • @instamusic7918
    @instamusic79183 жыл бұрын

    One of the best python program langauge channel on youtube, Thanks brother from India.

  • @TriStrideDad
    @TriStrideDad4 жыл бұрын

    Absolutely recommended video. Crisp and Clear

  • @atulpanthri4729
    @atulpanthri47293 жыл бұрын

    You have very deep understanding of python, teaching and choosing examples. Its really hard to understand where general student fail and get frustrated and you know this all. Thanks a lot Sir

  • @RRatedT
    @RRatedT4 жыл бұрын

    I love your videos man, seriously I don't get it why in college they don't explain it like you do- I just understood a lot about Python thanks to you. I'm dead serious I was frustrated I didn't got it right, thank you very much for sharing your knowledge !

  • @BANDITRYBAND
    @BANDITRYBAND7 жыл бұрын

    Very useful tutorials! The pace and info is spot on and invaluable to me. Thank you!

  • @zes7215

    @zes7215

    5 жыл бұрын

    ts not interesx or intimidax, no intimidax for such or anyx. diffix doesnt matter

  • @szabikrdev5066
    @szabikrdev50662 жыл бұрын

    Really clean explanation. Thank you soo much!

  • @clearair
    @clearair6 жыл бұрын

    Really amazing content Corey - really useful detail presented a brisk pace. Thanks so much!

  • @monagulapa3022
    @monagulapa30225 жыл бұрын

    When I was self studying C# because my job needed it, I hardly grasped the concept of OOP because coding it in C# to see how it actually works is complicated. With your explanation, I saw the clear and complete picture of OOP. Maraming Salamat ! (Thank you so much ! 🙂)

  • @uptopaviation
    @uptopaviation2 жыл бұрын

    Each and every one of your videos is amazing. Thanks for the great content!

  • @vm7240
    @vm7240 Жыл бұрын

    Thanks a bunch! Your videos are to the point, concise and yet, very well explained.

  • @vladn.2332
    @vladn.23326 жыл бұрын

    Thank you for your videos, Corey! It really helped me better understand how to work with classes in Python :)

  • @cysage5876
    @cysage58764 жыл бұрын

    You just opened a whole new page of programming to me. Before this I didn’t fully understand oop. Thank you 👍

  • @DShawnPaytonOffiicial
    @DShawnPaytonOffiicial Жыл бұрын

    I just want to say, your videos are excellent. You provide a clear explaination of everything. Thank you. I was having issues with __repr__ and __str__ until I realized that I was putting them in the wrong class. Hopefully this will help anyone else having similar issues.

  • @biswajitpaul3843
    @biswajitpaul38437 жыл бұрын

    All your videos are very useful. Keep it up.

  • @Fourty_7
    @Fourty_75 жыл бұрын

    Thnx for the video Corey, now i can understand the special methods a little bit

  • @TheSoftwareServices
    @TheSoftwareServices2 жыл бұрын

    Really Awesome, Amazing flow of wording and content presentation. Thank you very much Schafer.

  • @nit235
    @nit2353 жыл бұрын

    We have to create another class to remove from KZread those who watched this video but didn't thank Corey. Thank you a lot Corey ! I'm a beginner not only in python, but in all programming languages , but I understood your teaching very well.

  • @Burgturdler2
    @Burgturdler2 Жыл бұрын

    Dude, you're awesome. Been binging your videos and they are helping a bunch. Excellent teaching ability!

  • @muhammadhassan5428
    @muhammadhassan54282 жыл бұрын

    You deliver the best explanations and clear presentations.

  • @Jeganbaskaran
    @Jeganbaskaran7 жыл бұрын

    Simply amazing!! The way you are representing anyone who can learn easily, I came from different language background and i can easily compare it the way you explained. Thanks for your videos. Keep it up.

  • @aman0509
    @aman05094 жыл бұрын

    You are great man!! You have helped me a lot in understanding many Python Concepts.

  • @venkysmoments9155
    @venkysmoments91557 жыл бұрын

    @corey - Your way of explaining the concepts are too good. Keep continue your work.Love your teaching skills. Kudos to you.

  • @loganinn3940
    @loganinn39404 жыл бұрын

    I watch this on June 29, 2020, and now I understand why you need __add/len/str/repr__ in a class. Best 30 minutes of time spent on learn and taking note.

  • @ankursrivastava2112
    @ankursrivastava21126 жыл бұрын

    Awesome tutorial.. superbly described oops concept... thanku very much..

  • @dixonstroi
    @dixonstroi3 жыл бұрын

    another great tutorial. really helping to tie together learning from text tutorials and excercises.

  • @Allomerus
    @Allomerus5 жыл бұрын

    Excellent explanation Corey. Thanks for sharing this!

  • @misterjaypeasmith
    @misterjaypeasmith4 жыл бұрын

    You make learning Python really enjoyable Corey 🙌🏽

  • @bhunakitchantaraseno7809
    @bhunakitchantaraseno78094 жыл бұрын

    great tutorial! I built my first app learning from your videos. Thank you!

  • @markcsizmadia2109
    @markcsizmadia21097 жыл бұрын

    this is just awesome! helps me a lot. thank you for your hard work!

  • @sebastianpanea652
    @sebastianpanea6525 жыл бұрын

    It really helped me :) ... I thought I can't understand this topic but you made It clear

  • @yuanfeilin4822
    @yuanfeilin48224 жыл бұрын

    So dunder is the abbreviation of double underscores!:-)

  • @l0remipsum991

    @l0remipsum991

    3 жыл бұрын

    __ = double underscores = dunder

  • @JS-ni7ly

    @JS-ni7ly

    3 жыл бұрын

    double underscores Mifflin this is Pam speaking...

  • @kakkaladeepak632
    @kakkaladeepak632 Жыл бұрын

    i really like ur tutorial i completely watched 4 vedios and 2 remaining i will do some practice questions and watch the remaining 2 vedios love from India Andhra Pradesh Vizag

  • @Prelude2ADream
    @Prelude2ADream6 жыл бұрын

    Really useful video. Well explained - thank you!

  • @ctianlong82
    @ctianlong823 жыл бұрын

    Thank you, sir. Your video really helps me to have a better understanding of the special methods.

  • @IterativeTheoryRocks
    @IterativeTheoryRocks4 жыл бұрын

    These are excellent videos. Thank you!

  • @bhaskargarai8371
    @bhaskargarai83714 жыл бұрын

    This guide helped me a lot....Showing appropriate examples for the methods...especially this one,and not only clear concepts,but also the way to make something understand is excellent....great job....

  • @elf3332
    @elf33325 жыл бұрын

    I love it! Amazing, keep going.

  • @josephmwangi1951
    @josephmwangi19515 жыл бұрын

    My code was crap before this series. But its a good thing, makes me appreciate everything you're teaching here. Thank you

  • @AJ-et3vf
    @AJ-et3vf2 жыл бұрын

    Awesome video! Thank you!

  • @ragavsathis
    @ragavsathis5 жыл бұрын

    excellent video- crisp points and ex. thanks very much

  • @ryanseideman6812
    @ryanseideman68128 жыл бұрын

    this video was magical!

  • @depressedknight369
    @depressedknight3694 жыл бұрын

    daamnnnn, wow this video was specifically very informative and full of some deep stuffs... thanks....

  • @MrI7asson
    @MrI7asson4 жыл бұрын

    Great video as usual, explaining the data model in Python, Thank you so much.

  • @kibuzz3258
    @kibuzz3258 Жыл бұрын

    your python tutorials are greatest, thank you so much!

  • @anjanghosal5684
    @anjanghosal56847 жыл бұрын

    Excellent tutorial set! Please keep them coming ....

  • @donmusicid
    @donmusicid7 жыл бұрын

    Its awesome! one of the best oop tutorial of python. Thanks

  • @m.y.s4260
    @m.y.s42605 жыл бұрын

    great tutorial, thank you so much!

  • @explorer9782
    @explorer97824 жыл бұрын

    Great Videos from you, You are helping many python newbies. please continue further with new python videos.