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

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ส.ค. 2024

ความคิดเห็น • 533

  • @kickbuttowsk2i
    @kickbuttowsk2i 4 ปีที่แล้ว +544

    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 3 ปีที่แล้ว

      @@sndselecta
      L

    • @timothywyatt722
      @timothywyatt722 3 ปีที่แล้ว +1

      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 3 ปีที่แล้ว +1

      @Timothy Wyatt instablaster =)

  • @ryanthornton3556
    @ryanthornton3556 ปีที่แล้ว +45

    6 years later and this is still invaluable

  • @garydunken7934
    @garydunken7934 7 ปีที่แล้ว +767

    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 ปีที่แล้ว +15

      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 5 ปีที่แล้ว +1

      @@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 ปีที่แล้ว +6

      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 ปีที่แล้ว +2

      Just like CS50. PLAIN & SIMPLE

  • @andresvodopivec5950
    @andresvodopivec5950 6 ปีที่แล้ว +341

    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  6 ปีที่แล้ว +26

      Thanks!

    • @mosesmbabaali9381
      @mosesmbabaali9381 4 ปีที่แล้ว +3

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

  • @christianfuchs9405
    @christianfuchs9405 6 ปีที่แล้ว +69

    best python tutorials on youtube. period.

  • @nelsongg347
    @nelsongg347 5 ปีที่แล้ว +40

    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
    @betulabendula6270 8 ปีที่แล้ว +56

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

  • @xiaolu7988
    @xiaolu7988 5 ปีที่แล้ว +12

    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!

  • @DiscoTile-LA
    @DiscoTile-LA 24 วันที่ผ่านมา +1

    The quality of your teaching is blowing my mind.

  • @ankurjain5286
    @ankurjain5286 8 ปีที่แล้ว +79

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

  • @sueholder703
    @sueholder703 4 ปีที่แล้ว +26

    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 ปีที่แล้ว +1

      Thanks!

  • @Mrjarnould
    @Mrjarnould 8 ปีที่แล้ว +96

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

  • @NicholasKimble
    @NicholasKimble 4 ปีที่แล้ว +2

    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!

  • @L0V3V4MP1R3
    @L0V3V4MP1R3 4 ปีที่แล้ว +17

    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! ♥

  • @bobboulden
    @bobboulden 3 ปีที่แล้ว +1

    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.

  • @baterickpatman
    @baterickpatman ปีที่แล้ว +1

    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

  • @tanmayag97
    @tanmayag97 4 ปีที่แล้ว +4

    Probably the best tutorial of OOPS in the world. 👌

  • @antonkamnev2067
    @antonkamnev2067 4 หลายเดือนก่อน +2

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

  • @GodsNode
    @GodsNode 6 ปีที่แล้ว +19

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

  • @kamalakannank3370
    @kamalakannank3370 2 ปีที่แล้ว +1

    One of best explanation learning video to understand class and object

  • @mrmabb123
    @mrmabb123 6 ปีที่แล้ว +17

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

  • @seymoreclearly
    @seymoreclearly 5 ปีที่แล้ว +3

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

  • @navroze92
    @navroze92 5 ปีที่แล้ว +6

    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.

  • @antonisvenianakis1047
    @antonisvenianakis1047 2 ปีที่แล้ว

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

  • @monagulapa3022
    @monagulapa3022 5 ปีที่แล้ว +2

    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 ! 🙂)

  • @returnedfaith7254
    @returnedfaith7254 6 ปีที่แล้ว +1

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

  • @instamusic7918
    @instamusic7918 3 ปีที่แล้ว +1

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

  • @Asparuh.Emilov
    @Asparuh.Emilov ปีที่แล้ว +3

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

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

  • @cipher6042
    @cipher6042 4 ปีที่แล้ว +3

    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!

  • @DShawnPaytonOffiicial
    @DShawnPaytonOffiicial ปีที่แล้ว +2

    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.

  • @user-qu2zc4rp9v
    @user-qu2zc4rp9v 6 ปีที่แล้ว +1

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

  • @billcallahan218
    @billcallahan218 9 หลายเดือนก่อน

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

  • @sreekanththota2200
    @sreekanththota2200 4 ปีที่แล้ว +3

    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

  • @dpynsnyl
    @dpynsnyl 4 ปีที่แล้ว +2

    I am an avid follower of your tutorials from the day TH-cam 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!

  • @JeremyFisher
    @JeremyFisher 4 ปีที่แล้ว

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

  • @dozieu8539
    @dozieu8539 3 ปีที่แล้ว

    Communication is so human and yet so otherworldy, thanks Corey

  • @cysage5876
    @cysage5876 4 ปีที่แล้ว +1

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

  • @nit235
    @nit235 3 ปีที่แล้ว

    We have to create another class to remove from TH-cam 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.

  • @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.. :)

  • @jamessmith732
    @jamessmith732 4 ปีที่แล้ว +2

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

  • @Caffeinegoesinface
    @Caffeinegoesinface 7 ปีที่แล้ว +13

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

  • @yahyakenoussi577
    @yahyakenoussi577 3 ปีที่แล้ว +1

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

  • @szabikrdev5066
    @szabikrdev5066 2 ปีที่แล้ว +1

    Really clean explanation. Thank you soo much!

  • @loganinn3940
    @loganinn3940 4 ปีที่แล้ว

    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.

  • @RRatedT
    @RRatedT 4 ปีที่แล้ว +3

    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 !

  • @yuanfeilin4822
    @yuanfeilin4822 4 ปีที่แล้ว +19

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

    • @l0remipsum991
      @l0remipsum991 3 ปีที่แล้ว +1

      __ = double underscores = dunder

    • @JS-ni7ly
      @JS-ni7ly 3 ปีที่แล้ว +2

      double underscores Mifflin this is Pam speaking...

  • @artmcclure637
    @artmcclure637 7 ปีที่แล้ว +9

    Finally, I understand Classes. Thank you!

  • @Dynamic.32
    @Dynamic.32 ปีที่แล้ว

    Great tutorial, it's rare to see tutorials demonstrate how it's implemented on real modules

  • @atulpanthri4729
    @atulpanthri4729 3 ปีที่แล้ว

    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

  • @kakkaladeepak632
    @kakkaladeepak632 2 ปีที่แล้ว +1

    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

  • @viniciuspantoja1979
    @viniciuspantoja1979 4 ปีที่แล้ว +1

    although I don't have a very advanced level of understanding of the English language, these tutorials are better than anyone in Portuguese, man, your tutorials are amazing, thanks so much!!

  • @muhammadhassan5428
    @muhammadhassan5428 2 ปีที่แล้ว +1

    You deliver the best explanations and clear presentations.

  • @CharlesDibsdale
    @CharlesDibsdale 7 ปีที่แล้ว +1

    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.

  • @anonymous_anonymity
    @anonymous_anonymity 5 ปีที่แล้ว +2

    One of the best python tutorials I’ve ever seen

  • @charlesfoster2644
    @charlesfoster2644 6 ปีที่แล้ว +38

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

  • @thangarajr9905
    @thangarajr9905 5 หลายเดือนก่อน +1

    whoo.. aha... Your videos, explanation, examples all are just amazing.... What can i say... Man, you are great teacher... full of Knowledge every millisecond of it

  • @BaranMedia-official
    @BaranMedia-official 4 ปีที่แล้ว

    I do not speak English very well,
    After six month of learning in many sites apps and courses I see that really the best place I learned easy is here, now I am 1 week here and I hope next year I reply this comment and I share what I learned Python with this good channel, remember always try to learn from some base place like SoloLearn or udemy then when you can not understand we’ll just come here, surely you will be happy both together, believe yourself

  • @bhunakitchantaraseno7809
    @bhunakitchantaraseno7809 4 ปีที่แล้ว +2

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

  • @gayatriborade9556
    @gayatriborade9556 2 ปีที่แล้ว +1

    Your way of explaining is very nice and understandable. Thank you so much sir 😊

  • @brunesi
    @brunesi ปีที่แล้ว

    I almost went researching if by any chance Dunder had another meaning than a name of a former owner of a Northeast Pennsylvannia paper company, but that's just 'Double UNDERscores'. Amazing.

  • @gershondevadason4656
    @gershondevadason4656 2 ปีที่แล้ว

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

  • @bhaskargarai8371
    @bhaskargarai8371 4 ปีที่แล้ว

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

  • @Sjongleringsmannen
    @Sjongleringsmannen 5 ปีที่แล้ว +1

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

  • @TheSoftwareServices
    @TheSoftwareServices 2 ปีที่แล้ว +1

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

  • @mokodo_
    @mokodo_ 4 ปีที่แล้ว +1

    best python tutorials on youtube. thanks!

  • @kibuzz3258
    @kibuzz3258 ปีที่แล้ว

    your python tutorials are greatest, thank you so much!

  • @pipertripp
    @pipertripp 5 ปีที่แล้ว +1

    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!

  • @kamolusmonov6540
    @kamolusmonov6540 5 ปีที่แล้ว +1

    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.

  • @venkysmoments9155
    @venkysmoments9155 7 ปีที่แล้ว +2

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

  • @burgundyhome7492
    @burgundyhome7492 2 วันที่ผ่านมา

    Dunder Methods: e.g. __init__
    A way to override the default behavior of a standard function (or operation).
    print(obj1) --> def __repr__ or __str__
    obj1 + obj2 --> def __add__
    len(obj1) --> def __len__
    **Don't mind me, I'm just putting this note for myself for future reference. ;-)

  • @ankitraj32112
    @ankitraj32112 ปีที่แล้ว

    python after so many years i have to rewatch it .

  • @TriStrideDad
    @TriStrideDad 4 ปีที่แล้ว +1

    Absolutely recommended video. Crisp and Clear

  • @yingjianhuang9030
    @yingjianhuang9030 2 ปีที่แล้ว

    Thanks for video, I was so confused about these magic methods previously.

  • @BANDITRYBAND
    @BANDITRYBAND 7 ปีที่แล้ว +3

    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

  • @djkunsal
    @djkunsal 5 ปีที่แล้ว +1

    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

  • @uptopaviation
    @uptopaviation 2 ปีที่แล้ว +1

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

  • @ramychaari2567
    @ramychaari2567 3 ปีที่แล้ว +2

    Another interesting fact is that print() calls the method __str__() automatically (or __repr__() if __str__() doesn’t exist) in other terms print(emp_1.__str__()) is the same as print(emp_1)
    Very good explanation I love your tutorials 👍

  • @KnightShade227
    @KnightShade227 4 ปีที่แล้ว

    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 😁

  • @josephmwangi1951
    @josephmwangi1951 5 ปีที่แล้ว +2

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

  • @aman0509
    @aman0509 4 ปีที่แล้ว +1

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

  • @Khushpich
    @Khushpich 4 ปีที่แล้ว +1

    Great tutorial, straight to the point. Thanks Corey!

  • @ctianlong82
    @ctianlong82 3 ปีที่แล้ว +1

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

  • @nikitakothari1959
    @nikitakothari1959 3 ปีที่แล้ว

    hi i am begginer in python. i am start learning with you video. very good video thank you

  • @pratyush_sahoo
    @pratyush_sahoo 2 ปีที่แล้ว

    This is my second or third comment in youtube after using it for 10years. Corey your plan and excution is superb, and it helped to learn a lot.

  • @Fourty_7
    @Fourty_7 5 ปีที่แล้ว +1

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

  • @easyscience2235
    @easyscience2235 4 ปีที่แล้ว +1

    Recap
    Magic methods also called Dunder Methods, contain two underscores before and after such as __init__
    Let us match built in functions and behaviours, we can also change or modify some built in functionallity especially with classes
    If you ant to print the object or instance and have it return something more user friendly.
    You can set a __repr__ method, you want this method to usually return a representation of the object, so that you can
    copy and paste into python to recreate the same object.
    For example emp1 = Employee("Jake", "Stevenson", 50000)
    repr(emp1)
    --> Employee("Jake", "Stevenson", 50000)
    The str Dunder can you return a more user friendly string for your instance.
    str(emp1)
    --> Jake Stevenson, pay 50000
    It is always good to have a repr Dunder, as it will check the str Dunder First, then if there is not one it will fall back to the str method
    There are a lot of magic methods some are for example the + operator can be seen as __add__ dunder.
    When we add two numbers it will return the sum print(2+1) --> 3
    When add two strings it will simply contacatinate them print('a' + 'b') --> ab
    What actually is happening is that since the 2 and 1 are integers, they are instances of the int class so are int objects.
    The addition can be seen as accessing the __add__ method from the integer class.
    print(int.__add__(2, 1)), which returns the sum.
    The same Dunder can be changed just like we did with the init dunder and others, if we have a string object such as "a"
    it will look in the str class to find that dunder operation, print(str.__add__('a', 'b')) which will then have different instructions
    and tells the computer to return the concatinated strings, return '%s%s'%('a', 'b').
    There are many other magic methods that are used throughout.

  • @explorer9782
    @explorer9782 4 ปีที่แล้ว +1

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

  • @christydiness6200
    @christydiness6200 5 ปีที่แล้ว +1

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

  • @ramrajecr777
    @ramrajecr777 ปีที่แล้ว +1

    Now that's extraordinary

  • @23TrevorE
    @23TrevorE 7 ปีที่แล้ว +1

    Yet another brilliant tutorial, Corey. Many thanks.

  • @Burgturdler2
    @Burgturdler2 ปีที่แล้ว

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

  • @baspass8578
    @baspass8578 4 ปีที่แล้ว +5

    Hi Corey, please make video on multiple inheritance , and a video giving
    a reason that why we should not pass mutable data types as arguments

  • @5ithofnov159
    @5ithofnov159 5 ปีที่แล้ว +1

    you should be a python teacher, i have learned so much from your videos

  • @MohiniPatidar-gb1ur
    @MohiniPatidar-gb1ur 2 หลายเดือนก่อน +1

    the video was very helpful. thank you

  • @AJ-et3vf
    @AJ-et3vf 2 ปีที่แล้ว +1

    Awesome video! Thank you!

  • @misterjaypeasmith
    @misterjaypeasmith 4 ปีที่แล้ว

    You make learning Python really enjoyable Corey 🙌🏽

  • @neorayohaion3141
    @neorayohaion3141 3 ปีที่แล้ว

    DUDE HUGE THANK YOU I FINALLY MANAGED TO UNDERSTAND THAT THING TY SO MUCH!!!!!

  • @jvsnyc
    @jvsnyc 3 ปีที่แล้ว

    Really appreciated that you go out of your way to say that implementing add for two employees together is a really questionable design, just used to get us used to the syntax. Most presentations just leave things there, with no hint to newbies that this is not something you should probably do in real life.