Python OOP Tutorial 4: Inheritance - Creating Subclasses

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

ความคิดเห็น • 1.2K

  • @scorpp149
    @scorpp149 7 ปีที่แล้ว +922

    omg...it's like you are ansewring our questions before we even ask them..brilliant thank you very much

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

      Yes. Wow. Perfect walk through. 10/10 quality. I cant get off this channel.

    • @tommyl3707
      @tommyl3707 3 หลายเดือนก่อน +1

      Honestly I was getting a lot of anxiety from watching subpar DataCamp courses and wanting to quit coding until I found these videos

  • @user-xc5xf8gp8n
    @user-xc5xf8gp8n 4 ปีที่แล้ว +780

    Corey talks about inheritance of classes in this video.
    1. What is inheritence?
    It is a method that allows us to create a new class that shares the same attributes and method with the original function, and add some extra functionality to the new class. It also does not disturb the original class.
    2. How to make a class inherit from another class?
    class Developer(Employee):
    3. Structure of classes and subclasses.
    When we input a function to a subclass, python follows the 'method resolution order', which is the chain of classes that it goes through to find what the method is. All classes have the built-in group of methods and attributes as their primary order.
    4. How to initiate the subclass so that it can handle more information than its original class can?
    There are 2 ways.
    first, using the super method as follows and pass in the arguments in interest.
    super.__init__()
    Second, call the parent's init method explicitly and pass in the arguments in interest.
    Employee.init(self, first, last, )
    5. Useful tools when exploring the inheritance system.
    .isinstance(instance, class)
    This method returns the boolean value of whether an instance belongs to a calss
    .issubclass(subclass, class)
    This method returns the boolean value of whether a class has inherited from the second class.
    6. Example of class inheritance
    Whisky library
    ++ when setting a default value for an ungiven argument, avoid using an empty mutable data type. That's a topic for another video.

  • @rakeshkottu
    @rakeshkottu 5 ปีที่แล้ว +134

    I almost gave up on oop and then watched this series..The best playlist about oop.

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

      We're on the same page here

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

      I just started learning and was looking for a good OOP tutorial, this one made them easy. I already kinda learnt Swift for few weeks and just realised that some of the concepts I was learning there was OOP and I just didn’t knew that it’s called OOP

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

      Good teacher makes everything differernt. Before i get started to learn oop in python, i leaned oop in java and c# from a good teacher. Now, it is easier to learn oop in any other language because logic is behind of these language are same.

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

      @@emreaka3965 who taught you java could you send the link pls

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

      @@mrhitsjr4775 It is in my native language. You cannot understand his lessons.

  • @MyTube4Utoo
    @MyTube4Utoo 6 ปีที่แล้ว +559

    One great thing about Corey's videos, you know it's safe to 'Like' them before you watch them! *lol*

    • @coreyms
      @coreyms  6 ปีที่แล้ว +37

      Thanks!

    • @ashishm8413
      @ashishm8413 6 ปีที่แล้ว +9

      I was about to make the same comment, then saw your post :)

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

      What I was about to say

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

      Too True .. So Very True

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

      Escape the Matrix Beware, the youtube algorithm might not count these likes since they might be flagged for vote brigarding or bot voting.
      Afaik, you have to watch a minimum amount first before your votes are counted.

  • @Jonathan-od5xc
    @Jonathan-od5xc 6 ปีที่แล้ว +221

    Your explanation and use of the terminology is flawless through these tutorials, and I can't begin to tell you how helpful that is!

    • @coreyms
      @coreyms  6 ปีที่แล้ว +16

      Thanks! Glad to hear it's helpful

  • @DigGil3
    @DigGil3 7 ปีที่แล้ว +787

    Corey should be paid more.

  • @calebmbugua7686
    @calebmbugua7686 5 ปีที่แล้ว +58

    Thanks Mr corey!!!From Kenya and youre basically my role model in your humble approach towards sharing knowldge with us...In my own way ill try help as many people in my vicinity...tell them code is not as difficult..just as you are teaching us to love code!!! Thnaks Corey!!!

    • @coreyms
      @coreyms  5 ปีที่แล้ว +11

      That’s great to hear!

  • @rogut8
    @rogut8 7 ปีที่แล้ว +231

    I have used Treehouse and currently I'm attending programming bootcamp, but only you can explain stuff so clearly. Once again - thanks a lot

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

      I concur with everything you and Lukaz R stated...

    • @Cloud-577
      @Cloud-577 3 ปีที่แล้ว +4

      Hey there I'm from Treehouse too!

  • @MarioIuliano
    @MarioIuliano 5 ปีที่แล้ว +28

    Studying data science at college and went through this topic in class and felt completely lost. Your tutorials made it click so easily and with no issues. Very well done Corey !

  • @ShivamSingh-bx5lg
    @ShivamSingh-bx5lg 5 ปีที่แล้ว +416

    Print(isinstance(Corey,Super_humans))
    True

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

      😂

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

      syntax error

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

      @@terence7592 print(isinstance(Corey, SuperHumans))
      >>> True

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

      @@aadilrashidnajar9468
      That's still wrong.
      >>> input
      output

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

      @@RecursiveTriforce 🤣🤣🤣🤣😂

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

    I have a confession - more and more videos I see from this playlist, the more I am in awe at how Corey manages to explain that often-missed 'WHY' along explaining the 'how'. The 'how' explanation is already brilliant, but that 'WHY' on the top... He just brute-forces it to click!

  • @vishwaskaupvijayananda3900
    @vishwaskaupvijayananda3900 5 ปีที่แล้ว +56

    I've done my share of research before stumbling across this lecture series.
    Of all the Courses on Lynda, Udemy, and Coursera this is by far the best video tutorial I've come across.
    Thanks a lot Corey!

    • @vijendrachauhan3962
      @vijendrachauhan3962 5 ปีที่แล้ว

      complete agree to you Vishwas, Corey presents the programming concepts in video so well that even complex topics are easy to understand. Keep up the good work Corey.

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

    This Python OOP Tutorial playlist is super useful for everybody, hats off Corey Schafer, Subscribed and watching your other useful tutorials.

  • @sebastianvbb
    @sebastianvbb 5 ปีที่แล้ว +7

    this is great, most people give such simple examples on youtube, that they undermine the purpose of having a class just to show you what you can do with it. That works if someone knows OOP very well, but for relatively new users its a mess. This is great stuff for me!

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

    Corey, This is not at all a long video, it's simply a gem on Python inheritance

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

    Honestly, the class tutorials are the best tutorials I have ever watched. You explain it in plain english, straight to the point and easy to understand. Thank you so much.

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

    If teaching is an Art, this guy is the Picasso of it.

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

    Everyone will become programmer if all the teachers are like you. Awesome.

  • @zachgoll
    @zachgoll 7 ปีที่แล้ว +6

    I just can't get over how clear and concise your tutorials are. Saves all of us newbies hours of suffering :)

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

    Honestly, you are the one of the finest teachers I came across! I also see the humbleness in you, people like you make a world better place.

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

    this cheeky man trying to give himself a bigger raise then the other employees

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

    2:45 - intro to Method resolution order and help() function
    6:06 - inheritance and super().__init__()
    10:50 - if attribute = None ... Else attribute
    16:00 - isinstance(self, ) and issubclass(, )
    17:36 - real world example

  • @jwolf2759
    @jwolf2759 8 ปีที่แล้ว +52

    Definitely one of the best explanations of inheritance I've seen. This whole series has been great... I've been writing scripts and small procedural programs for years, but have only recently started using classes and sub-classes. I wish this series had been around when I first started trying to learn about class years ago.

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

    My god, the level of clarity that you possess and are able to transfer forward is just unbelievable.
    Thank you so much for all your hard work!

  • @flybyanuj
    @flybyanuj 7 ปีที่แล้ว +38

    I cannot even express how incredibly useful and precise your videos are. Thank you Corey!

  • @himansuodedra2201
    @himansuodedra2201 6 ปีที่แล้ว +33

    these explanations are beyond amazing. bought a course on udemy (best selling course to be specific) and what you have been able to explain to us in 6 videos has taken the course approximately 40 lectures!!!!

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

      I did the same thing. The Udemy course is a bunch of useless code snippets. But You build things that are useful in the real world and help me be more creative.

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

      That's deliberately done by Udemy so it feels like you're getting a lot of content. It's essentially bloat training. :D

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

    The explanation with the super__init__ method was flawless. 10/10

  • @Keyandcartracking
    @Keyandcartracking 6 ปีที่แล้ว +3

    Corey... out of all the tutorials I have watched on Python. Yours are the best! You have a great ability to explain things in a way that is much easier to comprehend!

  • @fwesselhoft
    @fwesselhoft 6 ปีที่แล้ว +10

    Currently taking a python class at Hopkins university and getting a bit loss on the class subject; your videos are super helpful and make the subject much easier to understand. Thank you, great work!

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

      Same when i learnt about oops. i was completely lost. This is the only instructor made me understand 😆

  • @jenmanzella1948
    @jenmanzella1948 5 ปีที่แล้ว +8

    The pacing for these lessons is perfect and the content is fantastic. Thank you so much for making these!

  • @sugatakar7738
    @sugatakar7738 5 ปีที่แล้ว +9

    Sir, you are undoubtedly one of the best Python tutors. Thanks so much for creating these awesome Python tutorials. :)

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

      He is not one of the best, He IS the best

  • @rajasekharreddy2410
    @rajasekharreddy2410 6 ปีที่แล้ว +7

    Any body can upload the videos,but the way of your explanations Superb......No one never beat you Dear.....

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

    All of Corey's videos are so good that I can feel a feeling of a bulb lighting up in my head. Like I achieved some enlightenment! In that case Corey is Buddha in Teaching. 😁

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

    If you're wondering and don't know why he didn't use default params like so: employees = [] (timing 11:24), you can consider the following scenario:
    Just create two managers without passing employee list in it. Add to one of them (via add_emp(self, emp)) new developer instance. Then print (print_emps) for both of them and you will see that one affects the other. This leads to unexpected behaviour. That's why he had to do so

    • @user-pk4cc1be8n
      @user-pk4cc1be8n 4 ปีที่แล้ว +1

      yes! but why? I am confused.

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

      In python, when you state a=b it means you identify a to b and then they share the same id. It's not a big deal in general but when b is mutable (like a list or set) and you modify it (with append, add etc), then a is modified too. Same problem occurs when you duplicate with *, for example if you want a 4*5 2dim-list full of 0s, it's a bad idea to use [[0]*5]*4, cause it creates indeed what you expect but all rows are identified thus if you modify, say, the [2][3] element, then [0][3], [1][3] and [3][3] are modified too, which, usually, is not the expected behaviour.
      The proper definition for our list would be [[0]*5 for _ in range(4)].

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

      That being said, would this one be a good statement to substitute all the if...else structure at 11:25?
      self.employees = [] if not employees else employees

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

      thank you. you are correct.

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

      @@user-pk4cc1be8n check the below video (@10:29) from Corey if you are still confused.
      th-cam.com/video/zdJEYhA2AZQ/w-d-xo.html

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

    You have done a great thing and even greater is the fact that you did not hide this stuff behind some "learning websites" , made it open to everyone in TH-cam. Thanks a lot

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

    This is hands down the cleanest and most concise explanation of class inheritance I've ever seen. I was never sure what super did throughout my entire computer science degree (I'm stupid) but this cleared it up nicely in a 20min vid. Don't stay in school kids!

  • @y.ulivee9015
    @y.ulivee9015 7 ปีที่แล้ว +6

    I just love the way you explain things, I could listen for hours. This is a really great series!

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

    Hey corey!
    I have bunch of courses from Udemy, Coursera, Bootcamp but nothing stands close to your explanation.
    Love from India

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

      Pls share the link of Bootcamp to download coz I cant find it in PlayStore..

  • @marcuswest4572
    @marcuswest4572 8 หลายเดือนก่อน +1

    This is a benchmark for teaching, period.

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

    No comments...No words!!! Such a cool mentor..Not sure I can see anybody else like you!!! Hitting Bulls-eye in every video..straight to the point..and in depth concept...

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

      Thanks!

  • @karthik-ex4dm
    @karthik-ex4dm 6 ปีที่แล้ว +7

    Python is just magical... Everything happens out of nothing
    I can visualize data structures such as linked lists etc from this lecture

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

    As soon as I'm getting my informatics degree you'll be invited to my party man, hell, I should give you half my salary for the rest of my life. Thank you so much.

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

    Salute to this man. He just had to fire himself to create this tutorial 💯

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

    I wonder why there are 62 thumbs down!!!! this guy is just amazing.... Thanks a lot....

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

    May I just say "Superb!" on your explanation of Inheritances / Subclasses along with your excellent and useful examples!!

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

    I'm so glad i've found your content! Finally i'm not getting distracted while listening! Your voice is calming and clear. Also somehow your explainations are interesting, and i find myself wanting to know more about the topic, which wasn't really the case with other tutiorials! Honestly i want to make tutorials too in the future, because i feel like when you teach, not one but actually two people are learning at that time. Repeatition is the key to becoming good in something, and when you repeat something while explaining it to someone, it becomes that much more effective. Keep up the good work!

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

    Best training on object oriented programming I've ever had. Seriously.

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

    Finally a good video with a good example rather than the print "parent class" and "subclass" XD

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

    bless your heart for making these videos

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

    This is an outstanding series, Corey. Thank you.

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

    Dear Corey, great videos and I tell you why: You dont steal my time. You speak fast without ehhhhs and ahhhhs but not as fast as if you were on drugs like so many others. You describe the subject in a constant "explanation speed" so when I m concnetrated, I get it all from the first to the last minute.
    Then you dont waste my time while typing. Almost no errors. Prepared stuff. Great. So with your videos I get a lot of information fast and complete. I'll donate something for this. I watched many many learning videos over the last years and yours is one of the best. Simple, quick, condensed, to the point, no selfish nonsense.

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

    I am a subscriber at Treehouse learning their Python course. I must admit, the instructor hasn't explained the dunder and inheritance syntax too well. But you did it flawlessly. Now it made so much more sense. Thank you.

  • @mikegropp
    @mikegropp 6 ปีที่แล้ว +3

    Very well done! Appreciate your videos, Corey. Your choice of words and pace is perfect for my current understanding of Python.

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

    Wish I watched your OOP videos two years ago when you posted them! :P Great tutorials and good working examples to help follow along.

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

    Just started to learn python from zero by myself and came accross classes not knowing what they actually are. These video-parts were the first one's recommmended upon searching on TH-cam and scrolling through the comments I've noticed that seemingly I'm saving a lot of time by avoiding videos from other channels. Thank you, Corey!

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

    So clear and precise...amazing video. I've see a lot of videos where people just run through projects with you and not really explaining the 'WHY' something is used or 'WHY'/'HOW' something happened, whether it be an error or a successfully executed line of code.....I think most tutorial videos focus too much on having people remember syntax... your videos are on-point. thanks a million.

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

    I'm a mechanical engineer, whose career died way before COVID dropped the last ton of dirt on top of its grave. I've been trying to re-skill my self into other industries of Mechanical Engineering, to learn some more process design stuff and migrate there; I like this Mechanical Engineering thing and I'm not about to give up. But those Mechanical Engineering courses are so incredible expensive, they are not meant for "outsiders" like me. Not only those courses are expensive, they are at times shallow and a sales pitch for: "tell your company to buy this other course where we go into greater detail. By the way, these other courses are on this other city so you can travel on company's dime and get paid to learn."
    It gets really expensive, and the instructor himself said the courses are not enough to break into that industry either way. The courses are meant to line the instructor pockets and pad the attendee resumes on their company.
    On the other hand, all the videos and resources I'm finding about coding, computer science and its kin; are not only FREE! they have depth, content and quality that I haven't seen in courses costing thousands of dollars in fancy Hotels.
    Corey Schafner, thank you so much for all of these Python courses. I'm beginning to entertain the idea of trying to migrate into coding or data science. I've always coded in ME and I have all the math either way.
    But...it's only a pipe dream. If I'm not able to get a job in ME after 2 years freelancing to scrape by, and having 8 years of experience as a Mechanical Engineer. I sincerely doubt anyone will accept an outsider into Information Technologies armed with youtube videos, Coursera certifications and zero years of coding.
    Once again, thank you for the work you put into these videos. And I really wish I could send something your way other than this self pitying rambling.

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

      Am 29 and have 8 years of experience in civil engineering, I didn’t liked coding in school and preferred CE over CS because my dads an construction contractor and no teacher actually taught me good. They were like include is something that all C programs should have and so you just memorise it. Never really taught about what’s binary and hexadecimals and taught us just how to do the conversion while it’s actually counting with 2 fingers and 6 fingers.
      After joining college I got an internet connection in home. Bought a mobile (Nokia N96)and tried to customise it. It all started there. My thirst for this. In fact python is the first code I used. Even though it wasn’t what I typed. I learnt swift for two weeks in lockdown. And kinda just like you bad marriage gave me anxiety, depression and other freebies that comes along with it. And COVID gave me the final blow. Am without job from Nov 2019 and still making my 60+ yo dad do business for me (small business so too much manual labor)
      After meeting psychiatrist I realised I should follow my passion. Eventhough I like CE I always wanted to make apps for construction industry which is still kinda old school and the existing ones are for big million dollar infra projects and doesn’t suit small businesses and our country. So with Excel & Apple Shortcuts app I made mini apps to suit my needs and it kinda worked. But the problem is adding more modules to it became time consuming because it wasn’t designed to do what I was doing.
      So I gave myself 6 months more to become an app and game developer.
      Now came here to learn python because of web scraping needs (for some background check to get rid of bad marriage) and I did it. So my first exposure to code is python and the first code I typed all by myself is python.
      We are in this together buddy. Keep learning on holidays and free time as side project. You will succeed.
      I have to take break because in work I don’t get time to do all these even on sundays.
      Am not sure what am talking now or what I said is appropriate. But keep in mind that you are not alone. Just don’t give up. And act fast I have been fiddling with basics of programming past few year and drop it, then start again. Instead just keep learning even if it’s a very slow pace. Just don’t give up.
      ALL THE BEST

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

    thank you again, so well explained . u are a gifted teacher Corey!

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

    I'm just watching and clapping. Everything is so easy to understand. Just brilliant. Thank you Corey!!!!!!!!!

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

    I am trying to avoid tutorials posted 2 and more years ago...but YOU ARE THE BEST...I got tired of chasing all those fresh tutorials an I am so grateful to find You. THANK YOU SO MUCH :)

  • @arunsaivemula1300
    @arunsaivemula1300 8 ปีที่แล้ว +57

    u r really cool man ...! from my side i request u to make tutorial series on django package...thanq...in advance

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

      Django!

    • @appwebexperts5249
      @appwebexperts5249 5 ปีที่แล้ว

      Django tutorials - th-cam.com/channels/Jh4EQMRPQf9Vw0ifMmv7bg.html

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

    I cannot thank you enough! You are amazing!
    Keep up the brilliant work! ^_^

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

    The most Concise form of learning black magic, if I have ever seen it, this is super compact and usable, simply Perfect!

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

    One of if not the best free python resources available even till today. I and so many others have learned so much from you man. Your content should be used to teach python at all universities lol. Thanks for all your amazing content man!

  • @lightninginmyhands4878
    @lightninginmyhands4878 5 ปีที่แล้ว +9

    You just blew my mind with `help()`!!

  • @cipcip4986
    @cipcip4986 6 ปีที่แล้ว +3

    best python tutorials

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

    Holy shit, I've been needing help on explaining the syntax for Classes for over a week now and these videos are GOLD. I think I set a personal record on fastest Subscribed click.

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

    hi, you are so far the greatest Python teacher on TH-cam who can clearly explain the class inheritance concept, the examples couldn't be better. Thanks so much/

  • @drewerving7428
    @drewerving7428 6 ปีที่แล้ว +9

    Where have you been my whole life?

  • @flx4087
    @flx4087 6 ปีที่แล้ว +3

    Thank you Corey, very helpful video.
    How would I build a from_string() alternative constructor (as shown in the Python OOP Tutorial 3) for the Developer class without having to rewrite the initial split (let's assume I need to do a little bite more complex stuff, for example dig trough a xml)?

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

    Corey Schafer you are a god in explaining Python OOP. Love these videos. Good job!

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

    Your explanations here are more worth than bitcoin at their peak. Thank you so so much. This is extremely helpful!

  • @ankitbiradar8599
    @ankitbiradar8599 7 ปีที่แล้ว +8

    Why do we need to implement super.__init__() in Developer.
    Developer already has these variables as it has inherited them from employee. What is the need for stating them explicitly again.

    • @BookOfSaints
      @BookOfSaints 7 ปีที่แล้ว

      I'd also like to know. I'm sure there is a reason, I am just curious! Thanks.

    • @danielschmidt7054
      @danielschmidt7054 7 ปีที่แล้ว +21

      super() is needed if you want to add code to the inherited function. If you try his example without it, you completely overwrite Employee.__init__() and the other attributes (first, last, etc) are not available to Developer.

    • @ShovelShovel
      @ShovelShovel 7 ปีที่แล้ว +11

      its because when you define __init__() in Developer it overrode the __init__() method so it doesn't actually inherit the __init__() from Employee anymore and those variables are no longer defined for Developer. so in your __init__() method in Developer you need to call the __init__() from Employee using super() or Employee.__init__(self).

    • @pinochska
      @pinochska 6 ปีที่แล้ว

      Wow, truly great teacher

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

      I think it is because you want to add prog_lang argument to it but you can't just "add" up it, so you need to rewrite the (first, last, pay) and then now you can just add (prog_lang) to it.

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

    There is bug in line 27 28
    java developer has more Salary than python developer 😂..

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

    It is so great that you show real world examples, on top of your first examples be thought out and making sense.

  • @Colstonewall
    @Colstonewall 8 ปีที่แล้ว

    I've gone over countless Python (and other) tutorials, and you're definitely the best teacher or at least in the top 2. This (video) is nothing new to me, but sometimes I go back and watch tuts just for a refresher or to see if I like the teacher. You make it easy to grasp, and in an exciting way.
    I hope you continue making tutorials, Corey, cause you're so damn good at it. Thanx again.

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

    is super broken in python 2.7.xx?
    throws below error
    TypeError: super() argument 1 must be type, not instance

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

      something has changed in python 3 regarding super().
      try this if you are using sublime :
      stackoverflow.com/questions/38963018/typeerror-super-takes-at-least-1-argument-0-given-error-is-specific-to-any

    • @holyproton8855
      @holyproton8855 6 ปีที่แล้ว

      Yeah super() doesn't seem to work for 2.7, but using the parent class with self will work though

    • @creativedev2802
      @creativedev2802 6 ปีที่แล้ว

      Employee.__İnit__(self,first,last,pay)
      self.prog_lang = prog_lang
      try this

  • @j.rob.5943
    @j.rob.5943 5 ปีที่แล้ว +3

    print(this_video.isGolden())
    >True

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

    Man..! . I am totally blown up with your teaching skills. Amazing you are. RIP to those thumbs went down.

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

    First time I understand why we use classes. You're the best!

  • @admiralspyro9722
    @admiralspyro9722 5 ปีที่แล้ว +19

    Developer earns 60000, Manager 90000, ... sad truth.

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

      Why sad? Natural thing :D Higher responsibility = higher salary. Or higher value of the work = higher salary.

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

      @@denisds130 I actually thin that it is sad and unfair in many cases. Btw I don't think that a scrum manager has much responsability or pressure. It is as if we would say that it is normal for politicians to make 200k a year, because they have higher responsabilities and values, that's not corrent. Same with mainstream journalists: they are well paid activists, they bring no value and their sole responsability is to bs their viewers while looking really moral and deeply outraged. They are worthless .

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

      @@MMABeijing No, they bring big value, which other people want pay for. If something is more desirable then it is better paid. Market rules. Politicians are not a part of the market - they are in government. Programmers are well paid because there is a big demand on their skills, which means that they have big value for employers.

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

      @@MMABeijing It's unfair that somebody who do not work gets free money which we all have to give him in taxes. It's unfair when someone has no skills, no productivity and he want more money because he "deserves" it. No. If you won't work for it, you will not have it. That is fair.

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

      @@denisds130 I would say that everybody , including lawyers/politicians/mainstream journalists are part of the market as a rational actor would/could decide to opt for those professions. My experience in IT (in telecommunications) had me witness very skilled programmers stuck in engineering work where there was little chance of promotions while a few people who could not make it in their technical work opted for working as project managers because it was in fact the easy way up. This was a major reason why there was a major and growing dissatisfaction within the R&D teams within *okia's team that I interviewed. At the same time that situation was dealt totally differently within Huawei where team managers and project managers had to have made their arms and proven excellent before they were put in a position of management. In that respect Huawei was doing a better job at dealing with a situation that was unfair from the perspective of the engineers interested in research and who wanted to work within a company where research and researchers would be the hear and sould of the organisation. I see your point, hopefully this longer post lets you see my original point better.

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

    Hi Corey. Thanks for the video.
    I didn't get the below part:
    class Managers(Employee):
    def __init__(self,first,last,pay,employees=None):
    Employee.__init__(self,first,last,pay)
    self.employees=employees
    Here you are instantiating as:
    mgr1=Manager(' Sue','Smith',90000,[dev1])
    But 'dev1' is an object(dev1=Developer('Corey','Schafer',50000,'Python') not a single entity(value). What values are getting passed in the list to 'mgr1'.
    Also after doing the same things, I am not able to print the employees using:
    def print_emps(self): method.
    I am getting:[] whenever I am trying to print.
    PS: I AM USING PYTHON 2.7.12.
    Thanks for the help.

    • @sdram111
      @sdram111 7 ปีที่แล้ว

      Hi Corey, am also having this doubt. Could you please answer to this question.

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

      [Ayush Gupta]
      dev1 = Developer('Corey','Schafer',50000,'Python')
      the above line creates the object of Developer class or instantiate the Developer class and you can pass the objects as list it, carries all the info with it.
      and about print_emps() i think you are just printing emp which corresponds to the object of developer class, you must do emp.fullname() which will call fullname method and is equivalent to dev1.fullname() or dev2.fullname() if it is there
      I hope this helps you understand .

    • @Sikkandarsulaiman
      @Sikkandarsulaiman 7 ปีที่แล้ว

      First I'll clarify about your print_emps(self)
      Sure you would have the statement
      -----------
      for emp in self.employees:
      print emp
      -----------
      inside your print_emps(self)
      You're getting this because you're printing the object itself, it leads to print the address of particular instance and not all its corresponding attributes. Thats the reason Corey mentioned to print the full name.
      Then, for a Python list, it can store an object. Of course objects are single entities. But remember its an instance, rather than an entity thats why you should print values associated with the instances and not the instances itself

    • @gautamj7450
      @gautamj7450 6 ปีที่แล้ว

      It's best to switch over to Python 3.6 ASAP! ;-)

    • @aishaverheecke7845
      @aishaverheecke7845 6 ปีที่แล้ว

      You should use the __str__ function, it returns a string from your function instead of the instance

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

    I tried to understand OOP, and watched so many other videos, but this one, is by far the best resource I've ever came across. Hats off!!!!

  • @photon-9551
    @photon-9551 4 หลายเดือนก่อน

    Thanks Corey
    the best example and explanation of how to extend a sub-class's parameters that I have come across on the web.
    keep up the good work!

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

    The best lectures about OOP and python I've ever listened to. Man, you are awesome.

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

      Definitely! I previously attended a python course about this same topic on udemy and Damm I didn't understand a word but after watching these videos my concepts are crystal clear.

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

    I came to watch this from a popular learning platform to understand python inheritance better. Thank you!

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

    3 years for this playlist
    But nothing can stand before this..
    Thank you corey sir..
    Love from india.

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

    I cannot express to you how helpful your videos have been. I have watched all my uni lectures and read so many articles explaining what classes are, but only your set of videos have gotten me to grasp the concept completely

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

    best python tutorial video ever, I have picked up a lot, thanks very much!

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

    The use of help( ) makes it so much more into the face, I love it!

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

    Corey, this is one of the best tutorials I have seen on inheritance! Thanks so much for a concise explanation. I have been developing OOP for a few years now and I learned a ton of stuff watching your videos. For using super in python 2.7, I had to modify the code a little bit as follows:
    class Employee(object):
    ...
    class Manager(Employee):
    raise_amount = 1.10
    def __init__(self, first, last, pay, employees=None):
    super(self.__class__, self).__init__(first, last, pay) #

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

      Thank you for sharing @Uma Nagaswamy. Your comment is still relevant 5 years later!

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

    Best OOP tutorial I found. I regret not sterting here. Thx!

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

    Wow the explanation of how Inheritance will be helpful in the end of the video was wonderful, my eyes are now open!

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

    Very explanatory examples nicely put. Whenever I get confused about a topic, or I want to learn something I find myself in your channel. And you are never a disappointment :)

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

    I feel the beginnings of a question formulating in my mind and then....BAM! Corey answers it before I even knew what I wanted to ask.

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

    Man, how can I say thank you so much in a different way... there are no words that can describe how awesome you are, I know this is common for you, but if you feel what I'm feeling right now you would have been (NO WORD TO DESCRIBE...).
    The awesome thing about you is that whenever I get bored of programming, I immediately watch a video of yours, then I recover my mental health.
    Please make new videos with new topics about Python and Python OOP. we need to master them with your help.

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

      Thanks! I really appreciate that

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

    You have a really suitable voice for this and the way you explain everything is just amazing Corey. The other short video tutorials on TH-cam only have about 5 min each, that's depressing. You are the best at this!

  • @k.c.krishna9570
    @k.c.krishna9570 ปีที่แล้ว +1

    The only channel that I double check pressing the like button...

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

    Your videos are so great that i watched them before class and then my professor reccomended your videos as extra practice.... already way ahead of you, professor

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

    your cleard my all nightmare of OOPs concepts,thank you very much from India