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.
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
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.
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.
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!!!
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 !
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!
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!
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.
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!
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.
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
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.
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!!!!
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.
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!
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!
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. 😁
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
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)].
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
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
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!
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...
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.
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!
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.
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.
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!
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.
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.
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
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 :)
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!
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.
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/
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)?
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.
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.
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).
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.
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.
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
@@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 .
@@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.
@@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.
@@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.
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.
[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 .
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
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.
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
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) #
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 :)
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.
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!
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
omg...it's like you are ansewring our questions before we even ask them..brilliant thank you very much
Yes. Wow. Perfect walk through. 10/10 quality. I cant get off this channel.
Honestly I was getting a lot of anxiety from watching subpar DataCamp courses and wanting to quit coding until I found these videos
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.
Nice recap
It's super().__init__()
Very useful comment.
Please modify syntax .
super().__init__()
And
Employee.__init__(self,)
WSGI library
Thanks buddy!
I almost gave up on oop and then watched this series..The best playlist about oop.
We're on the same page here
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
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.
@@emreaka3965 who taught you java could you send the link pls
@@mrhitsjr4775 It is in my native language. You cannot understand his lessons.
One great thing about Corey's videos, you know it's safe to 'Like' them before you watch them! *lol*
Thanks!
I was about to make the same comment, then saw your post :)
What I was about to say
Too True .. So Very True
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.
Your explanation and use of the terminology is flawless through these tutorials, and I can't begin to tell you how helpful that is!
Thanks! Glad to hear it's helpful
Corey should be paid more.
raise_amt = 200
@@spongmoid842 lol dude😂
@@spongmoid842 lmao😂
:))) definitely!
Indeed
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!!!
That’s great to hear!
I have used Treehouse and currently I'm attending programming bootcamp, but only you can explain stuff so clearly. Once again - thanks a lot
I concur with everything you and Lukaz R stated...
Hey there I'm from Treehouse too!
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 !
Print(isinstance(Corey,Super_humans))
True
😂
syntax error
@@terence7592 print(isinstance(Corey, SuperHumans))
>>> True
@@aadilrashidnajar9468
That's still wrong.
>>> input
output
@@RecursiveTriforce 🤣🤣🤣🤣😂
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!
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!
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.
This Python OOP Tutorial playlist is super useful for everybody, hats off Corey Schafer, Subscribed and watching your other useful tutorials.
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!
Corey, This is not at all a long video, it's simply a gem on Python inheritance
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.
If teaching is an Art, this guy is the Picasso of it.
Everyone will become programmer if all the teachers are like you. Awesome.
I just can't get over how clear and concise your tutorials are. Saves all of us newbies hours of suffering :)
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.
this cheeky man trying to give himself a bigger raise then the other employees
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
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.
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!
I cannot even express how incredibly useful and precise your videos are. Thank you Corey!
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!!!!
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.
That's deliberately done by Udemy so it feels like you're getting a lot of content. It's essentially bloat training. :D
The explanation with the super__init__ method was flawless. 10/10
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!
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!
Same when i learnt about oops. i was completely lost. This is the only instructor made me understand 😆
The pacing for these lessons is perfect and the content is fantastic. Thank you so much for making these!
Sir, you are undoubtedly one of the best Python tutors. Thanks so much for creating these awesome Python tutorials. :)
He is not one of the best, He IS the best
Any body can upload the videos,but the way of your explanations Superb......No one never beat you Dear.....
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. 😁
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
yes! but why? I am confused.
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)].
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
thank you. you are correct.
@@user-pk4cc1be8n check the below video (@10:29) from Corey if you are still confused.
th-cam.com/video/zdJEYhA2AZQ/w-d-xo.html
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
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!
I just love the way you explain things, I could listen for hours. This is a really great series!
Hey corey!
I have bunch of courses from Udemy, Coursera, Bootcamp but nothing stands close to your explanation.
Love from India
Pls share the link of Bootcamp to download coz I cant find it in PlayStore..
This is a benchmark for teaching, period.
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...
Thanks!
Python is just magical... Everything happens out of nothing
I can visualize data structures such as linked lists etc from this lecture
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.
Salute to this man. He just had to fire himself to create this tutorial 💯
I wonder why there are 62 thumbs down!!!! this guy is just amazing.... Thanks a lot....
May I just say "Superb!" on your explanation of Inheritances / Subclasses along with your excellent and useful examples!!
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!
Best training on object oriented programming I've ever had. Seriously.
Finally a good video with a good example rather than the print "parent class" and "subclass" XD
bless your heart for making these videos
This is an outstanding series, Corey. Thank you.
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.
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.
Very well done! Appreciate your videos, Corey. Your choice of words and pace is perfect for my current understanding of Python.
Wish I watched your OOP videos two years ago when you posted them! :P Great tutorials and good working examples to help follow along.
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!
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.
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.
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
thank you again, so well explained . u are a gifted teacher Corey!
I'm just watching and clapping. Everything is so easy to understand. Just brilliant. Thank you Corey!!!!!!!!!
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 :)
u r really cool man ...! from my side i request u to make tutorial series on django package...thanq...in advance
Django!
Django tutorials - th-cam.com/channels/Jh4EQMRPQf9Vw0ifMmv7bg.html
I cannot thank you enough! You are amazing!
Keep up the brilliant work! ^_^
The most Concise form of learning black magic, if I have ever seen it, this is super compact and usable, simply Perfect!
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!
You just blew my mind with `help()`!!
best python tutorials
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.
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/
Where have you been my whole life?
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)?
Corey Schafer you are a god in explaining Python OOP. Love these videos. Good job!
Your explanations here are more worth than bitcoin at their peak. Thank you so so much. This is extremely helpful!
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.
I'd also like to know. I'm sure there is a reason, I am just curious! Thanks.
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.
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).
Wow, truly great teacher
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.
There is bug in line 27 28
java developer has more Salary than python developer 😂..
It is so great that you show real world examples, on top of your first examples be thought out and making sense.
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.
is super broken in python 2.7.xx?
throws below error
TypeError: super() argument 1 must be type, not instance
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
Yeah super() doesn't seem to work for 2.7, but using the parent class with self will work though
Employee.__İnit__(self,first,last,pay)
self.prog_lang = prog_lang
try this
print(this_video.isGolden())
>True
lol this was so funny
Man..! . I am totally blown up with your teaching skills. Amazing you are. RIP to those thumbs went down.
First time I understand why we use classes. You're the best!
Developer earns 60000, Manager 90000, ... sad truth.
Why sad? Natural thing :D Higher responsibility = higher salary. Or higher value of the work = higher salary.
@@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 .
@@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.
@@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.
@@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.
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.
Hi Corey, am also having this doubt. Could you please answer to this question.
[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 .
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
It's best to switch over to Python 3.6 ASAP! ;-)
You should use the __str__ function, it returns a string from your function instead of the instance
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!!!!
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!
The best lectures about OOP and python I've ever listened to. Man, you are awesome.
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.
I came to watch this from a popular learning platform to understand python inheritance better. Thank you!
3 years for this playlist
But nothing can stand before this..
Thank you corey sir..
Love from india.
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
best python tutorial video ever, I have picked up a lot, thanks very much!
The use of help( ) makes it so much more into the face, I love it!
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) #
Thank you for sharing @Uma Nagaswamy. Your comment is still relevant 5 years later!
Best OOP tutorial I found. I regret not sterting here. Thx!
Wow the explanation of how Inheritance will be helpful in the end of the video was wonderful, my eyes are now open!
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 :)
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.
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.
Thanks! I really appreciate that
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!
The only channel that I double check pressing the like button...
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
your cleard my all nightmare of OOPs concepts,thank you very much from India