Python OOP Tutorial 4: Inheritance - Creating Subclasses

Python OOP Tutorial 4: Inheritance - Creating Subclasses

Corey Schafer

8 лет назад

1,424,638 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@grandlibulu3701
@grandlibulu3701 - 13.03.2025 19:32

This man is a wizard 🧙‍♂️ Corey is a python docs alive ❤

Ответить
@girishdevappa5562
@girishdevappa5562 - 12.03.2025 09:31

Thanks for the Post.
Regards,
Giri.

Ответить
@databridgeconsultants9163
@databridgeconsultants9163 - 25.02.2025 12:46

What an explanation Corey ! I come back here again and again whenever I get lost in OOPS concept. This is killer stuff. Thank You very much.

Ответить
@BarucGracia
@BarucGracia - 06.02.2025 10:23

Amazing

Ответить
@debatradas1597
@debatradas1597 - 02.02.2025 23:29

thank you so much

Ответить
@foadghasemi4709
@foadghasemi4709 - 02.02.2025 09:51

you're just awesome man t ks a lot

Ответить
@lotheravanti4295
@lotheravanti4295 - 28.01.2025 13:20

One of the best explanations I've found on the subject. The examples are easy to understand and you don't rush anything. Thank you.

Ответить
@helloparviz
@helloparviz - 12.01.2025 11:16

perfect explanation! perfect!!

Ответить
@GoodProgrammer92
@GoodProgrammer92 - 07.01.2025 23:47

Everytime I have an interview, I comeback here.

Ответить
@X95_Vampire
@X95_Vampire - 26.12.2024 15:08

Let me say loved this video and the bestttt for learning classes❤❤❤❤

Ответить
@dc3295
@dc3295 - 11.12.2024 03:38

corey is a great teacher. his content is well thought out and he explains things efficiently.

Ответить
@BijouBakson
@BijouBakson - 07.12.2024 16:22

Thank you

Ответить
@913egok
@913egok - 30.11.2024 14:57

Very useful videos on Python class. Thank you very much. I'd be completely lost without these.

Ответить
@LouaiEleslamboly
@LouaiEleslamboly - 26.10.2024 10:27

amazing explanation, thank you for sharing the knowledge

Ответить
@Nathan-f4d
@Nathan-f4d - 15.10.2024 19:45

watching in October 🤔2024, cheers! 🍺

Ответить
@Siddharth_Matada
@Siddharth_Matada - 15.10.2024 14:04

Superb Explanation...

Ответить
@setzz69
@setzz69 - 02.10.2024 21:32

Show me a better teacher! Cant find any. Corey is super brilliant! Makes complex concepts look like ABC stuff👋👋

Ответить
@jpan4438
@jpan4438 - 29.08.2024 10:49

Is Developer a subclass of Developer? Answer is True.

Ответить
@RudraKumarSharma-u9s
@RudraKumarSharma-u9s - 26.08.2024 21:16

watching this after 8 years and still wonderful

Ответить
@alhabib_o
@alhabib_o - 18.08.2024 22:46

"""
[1] What is Inheritance?

- Inheritance allows a class to inherit attributes and methods from another class.
- The class that is inherited from is called the parent class or *superclass*.
- The class that inherits from the parent class is called the child class or *subclass*.
- Inheritance promotes code reusability and can help in creating a hierarchy of classes.


[2] Creating a Subclass:

- To create a subclass, define a new class with the name of the subclass and specify the parent
class in parentheses.
- Syntax: `class SubClassName(ParentClassName):`
- The subclass inherits all attributes and methods from the parent class unless overridden.


[3] Overriding Methods:

- A subclass can override methods from its parent class to provide a specific implementation.
- This is done by defining a method with the same name in the subclass.
- If a method is overridden, the subclass version is used instead of the parent class version.


[4] The `super()` Function:

- The `super()` function is used to call a method from the parent class in the subclass.
- This is commonly used in the subclass's `__init__` method to initialize the parent class
attributes.
- Syntax: `super().method_name()`


[5] When to Use Inheritance?

- Use inheritance to create a natural hierarchy between classes.
- Ideal when one class is a specialized version of another (e.g., a Dog class that inherits
from an Animal class).
- Helps in code reusability and organization.

"""

Ответить
@DiscoTile-LA
@DiscoTile-LA - 04.08.2024 05:57

Thank you so much!

Ответить
@lhcunha1
@lhcunha1 - 01.08.2024 17:58

great lesson

Ответить
@davidsaiz9949
@davidsaiz9949 - 23.07.2024 19:29

why do you set employees=0 under class manager

Ответить
@ss4yaasir524
@ss4yaasir524 - 09.07.2024 22:02

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!

Ответить
@FaberLSH
@FaberLSH - 03.07.2024 07:56

Thank you so much!!

Ответить
@greghumphris174
@greghumphris174 - 07.06.2024 09:42

Great job Corey. You have explained the topic very well!

Ответить
@Killzu45
@Killzu45 - 17.05.2024 17:10

Can someone tell me which IDE Corey is using?

Ответить
@guristu
@guristu - 10.05.2024 03:34

If you have OCD, __init__() and super().__init__() buggs the hell out of you :)

Ответить
@kalpeshpatel3900
@kalpeshpatel3900 - 02.05.2024 04:48

Liked the real world example at the end! Great video!

Ответить
@photon-9551
@photon-9551 - 06.04.2024 14:28

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!

Ответить
@em2129
@em2129 - 21.03.2024 01:26

I finally get it, thank you!

Ответить
@CmdtJoshua
@CmdtJoshua - 17.03.2024 19:29

Amazing tutorial, helped me a lot. Thank you!

Ответить
@MrTb2arvd
@MrTb2arvd - 03.03.2024 23:59

great vids and content, Corey!

Ответить
@see576
@see576 - 05.02.2024 23:29

Thanks a lot, great explanantion

Ответить
@Tarunsinghnoble
@Tarunsinghnoble - 20.01.2024 08:32

I must say, I have TCM security subscription for python 201 which has a similar lecture on "Inheritance". TBH Corey provided more key points

Ответить
@LilJollyJoker
@LilJollyJoker - 18.01.2024 20:14

Thank you!

Ответить
@siddhigolatkar8558
@siddhigolatkar8558 - 08.01.2024 15:47

Thank you

Ответить
@escobol
@escobol - 07.01.2024 15:23

thank you so helpful!

Ответить
@damiandamian7344
@damiandamian7344 - 04.01.2024 18:45

I havent taken my comp sci class in about a year and its really nice to relearn the materials through these videos, thanks for all the help.

Ответить
@marcuswest4572
@marcuswest4572 - 01.01.2024 13:54

This is a benchmark for teaching, period.

Ответить
@CAROL.0909
@CAROL.0909 - 20.12.2023 07:34

Thank you for creating this video for us. I have a question. I noticed that you didn’t add “self.” in method “add_emp”. Shouldn’t it be “self.emp”?

Ответить
@matras6664
@matras6664 - 14.12.2023 15:54

q

Ответить