Python OOP Tutorial 4: Inheritance - Creating Subclasses

  Рет қаралды 1,340,910

Corey Schafer

Corey Schafer

Күн бұрын

In this Python Object-Oriented Tutorial, we will be learning about inheritance and how to create subclasses. Inheritance allows us to inherit attributes and methods from a parent class. This is useful because we can create subclasses and get all of the functionality of our parents class, and have the ability to overwrite or add completely new functionality without affecting the parents class in any ways. Let's get started.
Python OOP 1 - Classes and Instances - • Python OOP Tutorial 1:...
Python OOP 2 - Class Variables - • Python OOP Tutorial 2:...
Python OOP 3 - Classmethods and Staticmethods - • Python OOP Tutorial 3:...
Python OOP 4 - Inheritance - • Python OOP Tutorial 4:...
Python OOP 5 - Special (Magic/Dunder) Methods - • Python OOP Tutorial 5:...
Python OOP 6 - Property Decorators - • Python OOP Tutorial 6:...
The code from this video can be found at:
github.com/CoreyMSchafer/code...
✅ Support My Channel Through Patreon:
/ coreyms
✅ Become a Channel Member:
/ @coreyms
✅ One-Time Contribution Through PayPal:
goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - coreyms.com/
My Second Channel - / coreymschafer
Facebook - / coreymschafer
Twitter - / coreymschafer
Instagram - / coreymschafer
#Python

Пікірлер: 1 200
@user-xc5xf8gp8n
@user-xc5xf8gp8n 4 жыл бұрын
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.
@ericervin2513
@ericervin2513 4 жыл бұрын
Nice recap
@priyankaanandnegi6377
@priyankaanandnegi6377 4 жыл бұрын
It's super().__init__()
@MohitFort
@MohitFort 4 жыл бұрын
Very useful comment. Please modify syntax . super().__init__() And Employee.__init__(self,)
@pledgesingle3136
@pledgesingle3136 3 жыл бұрын
WSGI library
@mayureshjoshi4616
@mayureshjoshi4616 3 жыл бұрын
Thanks buddy!
@ShivamSingh-bx5lg
@ShivamSingh-bx5lg 5 жыл бұрын
Print(isinstance(Corey,Super_humans)) True
@JacobScott0000
@JacobScott0000 4 жыл бұрын
😂
@terence7592
@terence7592 4 жыл бұрын
syntax error
@aadilrashidnajar9468
@aadilrashidnajar9468 4 жыл бұрын
@@terence7592 print(isinstance(Corey, SuperHumans)) >>> True
@RecursiveTriforce
@RecursiveTriforce 3 жыл бұрын
@@aadilrashidnajar9468 That's still wrong. >>> input output
@g__shan
@g__shan 3 жыл бұрын
@@RecursiveTriforce 🤣🤣🤣🤣😂
@DigGil3
@DigGil3 7 жыл бұрын
Corey should be paid more.
@spongmoid842
@spongmoid842 5 жыл бұрын
raise_amt = 200
@gingerboy9170
@gingerboy9170 5 жыл бұрын
@@spongmoid842 lol dude😂
@muhammadmuinmundzir9981
@muhammadmuinmundzir9981 4 жыл бұрын
@@spongmoid842 lmao😂
@TheAryedemented
@TheAryedemented 4 жыл бұрын
:))) definitely!
@Felipe-53
@Felipe-53 4 жыл бұрын
Indeed
@scorpp149
@scorpp149 7 жыл бұрын
omg...it's like you are ansewring our questions before we even ask them..brilliant thank you very much
@josecruz2574
@josecruz2574 4 жыл бұрын
Yes. Wow. Perfect walk through. 10/10 quality. I cant get off this channel.
@tommyl3707
@tommyl3707 Ай бұрын
Honestly I was getting a lot of anxiety from watching subpar DataCamp courses and wanting to quit coding until I found these videos
@MyTube4Utoo
@MyTube4Utoo 6 жыл бұрын
One great thing about Corey's videos, you know it's safe to 'Like' them before you watch them! *lol*
@coreyms
@coreyms 6 жыл бұрын
Thanks!
@ashishm8413
@ashishm8413 6 жыл бұрын
I was about to make the same comment, then saw your post :)
@parthshah100
@parthshah100 6 жыл бұрын
What I was about to say
@arghoshj
@arghoshj 6 жыл бұрын
Too True .. So Very True
@jqbscorner
@jqbscorner 5 жыл бұрын
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.
@rakeshkottu
@rakeshkottu 4 жыл бұрын
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 жыл бұрын
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 2 жыл бұрын
@@emreaka3965 who taught you java could you send the link pls
@emreaka3965
@emreaka3965 2 жыл бұрын
@@mrhitsjr4775 It is in my native language. You cannot understand his lessons.
@vinnyisntgud7221
@vinnyisntgud7221 4 жыл бұрын
this cheeky man trying to give himself a bigger raise then the other employees
@rogut8
@rogut8 7 жыл бұрын
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 жыл бұрын
I concur with everything you and Lukaz R stated...
@Cloud-577
@Cloud-577 3 жыл бұрын
Hey there I'm from Treehouse too!
@Jonathan-od5xc
@Jonathan-od5xc 6 жыл бұрын
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 жыл бұрын
Thanks! Glad to hear it's helpful
@calebmbugua7686
@calebmbugua7686 5 жыл бұрын
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 жыл бұрын
That’s great to hear!
@Aaronisification
@Aaronisification 3 жыл бұрын
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
@MarioIuliano
@MarioIuliano 4 жыл бұрын
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 !
@manakupadhyay
@manakupadhyay 4 жыл бұрын
If teaching is an Art, this guy is the Picasso of it.
@hatani
@hatani 4 жыл бұрын
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 жыл бұрын
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 жыл бұрын
This Python OOP Tutorial playlist is super useful for everybody, hats off Corey Schafer, Subscribed and watching your other useful tutorials.
@sebastianvbb
@sebastianvbb 5 жыл бұрын
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!
@flybyanuj
@flybyanuj 7 жыл бұрын
I cannot even express how incredibly useful and precise your videos are. Thank you Corey!
@jwolf2759
@jwolf2759 7 жыл бұрын
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.
@jenmanzella1948
@jenmanzella1948 5 жыл бұрын
The pacing for these lessons is perfect and the content is fantastic. Thank you so much for making these!
@zachgoll
@zachgoll 7 жыл бұрын
I just can't get over how clear and concise your tutorials are. Saves all of us newbies hours of suffering :)
@sumitchhabra2419
@sumitchhabra2419 4 жыл бұрын
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..
@himansuodedra2201
@himansuodedra2201 6 жыл бұрын
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 жыл бұрын
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 жыл бұрын
That's deliberately done by Udemy so it feels like you're getting a lot of content. It's essentially bloat training. :D
@PerfectSwingDance
@PerfectSwingDance 4 жыл бұрын
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 жыл бұрын
yes! but why? I am confused.
@pierreardouin6441
@pierreardouin6441 4 жыл бұрын
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 жыл бұрын
@@user-pk4cc1be8n check the below video (@10:29) from Corey if you are still confused. kzbin.info/www/bejne/sJWtdoyedpd0kLM
@y.ulivee9015
@y.ulivee9015 6 жыл бұрын
I just love the way you explain things, I could listen for hours. This is a really great series!
@Keyandcartracking
@Keyandcartracking 6 жыл бұрын
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!
@richardfriedrichsen5339
@richardfriedrichsen5339 Жыл бұрын
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.
@fwesselhoft
@fwesselhoft 6 жыл бұрын
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 11 ай бұрын
Same when i learnt about oops. i was completely lost. This is the only instructor made me understand 😆
@hiseggcelency
@hiseggcelency 4 жыл бұрын
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!
@SAJITAHAMED
@SAJITAHAMED 6 жыл бұрын
Everyone will become programmer if all the teachers are like you. Awesome.
@arpitanand4693
@arpitanand4693 Жыл бұрын
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!
@jerrywang3225
@jerrywang3225 6 жыл бұрын
hi, you are so far the greatest Python teacher on KZbin who can clearly explain the class inheritance concept, the examples couldn't be better. Thanks so much/
@suryakiransuravarapu8081
@suryakiransuravarapu8081 2 жыл бұрын
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.
@itshowiedo
@itshowiedo 6 жыл бұрын
May I just say "Superb!" on your explanation of Inheritances / Subclasses along with your excellent and useful examples!!
@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
@Colstonewall
@Colstonewall 7 жыл бұрын
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.
@rajasekharreddy2410
@rajasekharreddy2410 6 жыл бұрын
Any body can upload the videos,but the way of your explanations Superb......No one never beat you Dear.....
@mikegropp
@mikegropp 5 жыл бұрын
Very well done! Appreciate your videos, Corey. Your choice of words and pace is perfect for my current understanding of Python.
@huntermaverick5114
@huntermaverick5114 6 жыл бұрын
You have a really suitable voice for this and the way you explain everything is just amazing Corey. The other short video tutorials on KZbin only have about 5 min each, that's depressing. You are the best at this!
@gokulsreekumar4371
@gokulsreekumar4371 6 жыл бұрын
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 KZbin. Thanks a lot
@alyssanguyen1354
@alyssanguyen1354 7 жыл бұрын
bless your heart for making these videos
@artemiasalina1860
@artemiasalina1860 5 жыл бұрын
This is an outstanding series, Corey. Thank you.
@chiragpalan9780
@chiragpalan9780 4 жыл бұрын
I wonder why there are 62 thumbs down!!!! this guy is just amazing.... Thanks a lot....
@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!!!!
@sugatakar7738
@sugatakar7738 5 жыл бұрын
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
@karthik-ex4dm
@karthik-ex4dm 5 жыл бұрын
Python is just magical... Everything happens out of nothing I can visualize data structures such as linked lists etc from this lecture
@arminneashrafi2846
@arminneashrafi2846 5 жыл бұрын
The most Concise form of learning black magic, if I have ever seen it, this is super compact and usable, simply Perfect!
@saifahmad141
@saifahmad141 Жыл бұрын
please never hesitate to make long videos . videos like these are pure gold. awesome explanation thank you Corey
@bartagas2
@bartagas2 5 жыл бұрын
Wish I watched your OOP videos two years ago when you posted them! :P Great tutorials and good working examples to help follow along.
@kinjomusic
@kinjomusic 5 жыл бұрын
thank you again, so well explained . u are a gifted teacher Corey!
@BradMeanswrgi
@BradMeanswrgi 4 жыл бұрын
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.
@jonspell88
@jonspell88 3 жыл бұрын
Best training on object oriented programming I've ever had. Seriously.
@varunnagrare4912
@varunnagrare4912 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. 😁
@mohitdaga2356
@mohitdaga2356 5 жыл бұрын
I cannot thank you enough! You are amazing! Keep up the brilliant work! ^_^
@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.
@keevee09
@keevee09 7 жыл бұрын
These video tutorials take me back to my days in lectures, learning about ADT's in Java. You provide a very clear and concise presentation at a good speed, broken into logical, digestible bites. Excellent work!
@sand9577
@sand9577 3 жыл бұрын
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
@arunsaivemula1300
@arunsaivemula1300 8 жыл бұрын
u r really cool man ...! from my side i request u to make tutorial series on django package...thanq...in advance
@DracoWF
@DracoWF 6 жыл бұрын
Django!
@appwebexperts5249
@appwebexperts5249 5 жыл бұрын
Django tutorials - kzbin.info/door/Jh4EQMRPQf9Vw0ifMmv7bg
@HaileeMiu
@HaileeMiu 5 жыл бұрын
It is so great that you show real world examples, on top of your first examples be thought out and making sense.
@bradyminer6471
@bradyminer6471 3 жыл бұрын
What I have been struggling to understand over the past few weeks you solved in one hour. Thank you so much!
@cipcip4986
@cipcip4986 6 жыл бұрын
best python tutorials
@lightninginmyhands4878
@lightninginmyhands4878 5 жыл бұрын
You just blew my mind with `help()`!!
@altunbikubra
@altunbikubra 3 жыл бұрын
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 :)
@jeff_mci_gaming6018
@jeff_mci_gaming6018 6 жыл бұрын
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.
@flx4087
@flx4087 6 жыл бұрын
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)?
@drewerving7428
@drewerving7428 6 жыл бұрын
Where have you been my whole life?
@MohammedAhmed-wq2jf
@MohammedAhmed-wq2jf 6 жыл бұрын
Corey, your videos are a delight for gaining clear understanding on python. Even Few of Udemy videos fail to deliver the way you have done. Thank you
@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 KZbin 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!
@rajatsharma2496
@rajatsharma2496 4 жыл бұрын
There is bug in line 27 28 java developer has more Salary than python developer 😂..
@ankitbiradar8599
@ankitbiradar8599 7 жыл бұрын
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 жыл бұрын
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 жыл бұрын
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 жыл бұрын
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.
@harrishandoko1558
@harrishandoko1558 5 жыл бұрын
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.
@Jtmxm
@Jtmxm 7 жыл бұрын
Corey, your lectures about class are really wonderful and clear to understand for beginners !!! I never find anyone else who talks about the class that clear.
@Jtmxm
@Jtmxm 7 жыл бұрын
In addition, would you please recommend me some tutorials concerning how python can treat large volume of data more quickly, for example, how we can run the codes on a serveur, distributed computing or how to use python with hadoop or map reduce. Thanks !
@4upranit
@4upranit 7 жыл бұрын
is super broken in python 2.7.xx? throws below error TypeError: super() argument 1 must be type, not instance
@mpagkalos93
@mpagkalos93 7 жыл бұрын
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 жыл бұрын
print(this_video.isGolden()) >True
@varishpersaud5093
@varishpersaud5093 4 жыл бұрын
lol this was so funny
@sayan2784
@sayan2784 4 жыл бұрын
I keep coming back to your tutorial again and again... you are the best!
@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 :)
@ayushgupta7731
@ayushgupta7731 7 жыл бұрын
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 жыл бұрын
[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 6 жыл бұрын
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
@admiralspyro9722
@admiralspyro9722 5 жыл бұрын
Developer earns 60000, Manager 90000, ... sad truth.
@denisds130
@denisds130 5 жыл бұрын
Why sad? Natural thing :D Higher responsibility = higher salary. Or higher value of the work = higher salary.
@MMABeijing
@MMABeijing 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 жыл бұрын
@@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 жыл бұрын
@@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 жыл бұрын
@@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.
@multiyumz
@multiyumz 5 жыл бұрын
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!
@bradleyshields230
@bradleyshields230 6 жыл бұрын
dude this is wonderful. you keep leading us to concepts, keeping it coherent....great job!
@AmanSingh-cb7om
@AmanSingh-cb7om 3 жыл бұрын
Thank you Corey! the best explanation of OOP on KZbin! Keep up the good work!!
@zaha7a752
@zaha7a752 4 жыл бұрын
Corey Schafer you are a god in explaining Python OOP. Love these videos. Good job!
@mohammednagdy6661
@mohammednagdy6661 6 жыл бұрын
First time I understand why we use classes. You're the best!
@Hyngvi
@Hyngvi 7 жыл бұрын
These videos are awesome - I like how you use simple examples but still go into the technical details! Good job!
@giorgipatsatsia544
@giorgipatsatsia544 3 жыл бұрын
I'm just watching and clapping. Everything is so easy to understand. Just brilliant. Thank you Corey!!!!!!!!!
@kalyanreddy4579
@kalyanreddy4579 4 жыл бұрын
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 4 жыл бұрын
Thanks!
@karennascimento6544
@karennascimento6544 7 жыл бұрын
Excellent series of videos covering classes, what they are for and how to use them. Very comprehensive in the way you build up from simple to more complex topics.
@sanidhyas3s
@sanidhyas3s 2 жыл бұрын
The use of help( ) makes it so much more into the face, I love it!
@bryanurizar
@bryanurizar 5 жыл бұрын
New to your channel and loving it. I'm currently working my way to a career change to become a software developer and loving your videos!
@NickSlaughterDude
@NickSlaughterDude 5 жыл бұрын
Phenomenal tutorial indeed. Well thought examples explained in clear and detailed manner. Thank you so much Corey.
@naveengorripati9227
@naveengorripati9227 6 жыл бұрын
Excellent videos, this is the best python material I have ever come across, hats off to you Corey
@danboterashvili276
@danboterashvili276 6 жыл бұрын
This course has been extremely helpful. So happy i discovered your channel from your podcast episode with Talk Python To Me. I look forward to learning more!
@OnlineMediaCollection
@OnlineMediaCollection 5 жыл бұрын
Your teaching skill is beyond others! Great job!!!
@boses5320
@boses5320 6 жыл бұрын
This is a very good video series, the whole O.O.P playlist. Corey u go through the basic very well and in a very informative way. Thanks a lot.
@sumitvaise5452
@sumitvaise5452 5 жыл бұрын
Corey thanks for such a helpful video. You are an inspiration for me. How easily you explain the logic is remarkable. THANKS a zillion.
@WIZURAI-AGV
@WIZURAI-AGV 5 жыл бұрын
explaining Python very clear, I think he is the best mentor in explaining Python. *thumbs up!
@simaphore
@simaphore 7 жыл бұрын
I had been trying to get this concept all day until I found this video and it answered all my questions! thank you!
@karimsid
@karimsid 5 жыл бұрын
excellent explanation with one example through out. I have been reading about the classes this video is one thorough answer to most of the questions I had. Corey is genius
@photon-9551
@photon-9551 3 ай бұрын
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!
@myusername6595
@myusername6595 5 жыл бұрын
definitely the best intro to OOP in general that i've found
Python OOP Tutorial 5: Special (Magic/Dunder) Methods
13:50
Corey Schafer
Рет қаралды 845 М.
Python OOP Tutorial 1: Classes and Instances
15:24
Corey Schafer
Рет қаралды 4,4 МЛН
Was ist im Eis versteckt? 🧊 Coole Winter-Gadgets von Amazon
00:37
SMOL German
Рет қаралды 31 МЛН
Получилось у Вики?😂 #хабибка
00:14
ХАБИБ
Рет қаралды 7 МЛН
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 170 #shorts
00:27
5 Good Python Habits
17:35
Indently
Рет қаралды 408 М.
super/MRO, Python's most misunderstood feature.
21:07
mCoding
Рет қаралды 213 М.
Python OOP Tutorial 3: classmethods and staticmethods
15:20
Corey Schafer
Рет қаралды 1,5 МЛН
Python Object Oriented Programming (OOP) - For Beginners
53:06
Tech With Tim
Рет қаралды 3,3 МЛН
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 247 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,1 МЛН
Was ist im Eis versteckt? 🧊 Coole Winter-Gadgets von Amazon
00:37
SMOL German
Рет қаралды 31 МЛН