Abstract Class and Abstract Method in Python

preview_player
Показать описание
Method which is decorated with @abstractmethod and does not have any definition.
Python Don't support Abstract class, So we have ABC(abstract Base Classes) Module, so we can use here to achieve abstract classes. And will see what is abstract class and why we need it. An abstract class can be considered as a pattern for other classes. A class which contains one or more abstract methods is called an abstract class. An abstract method is a method that has a declaration but does not have an implementation.

Support by

Editing Monitors :

Editing Laptop :

Mics

Follow on Facebook:

Subscribe to our other channel:
Telusko Hindi :

Subscribe to the channel and learn Programming in easy way.

Рекомендации по теме
Комментарии
Автор

Summary:
abstract method is a method which only has declaration and doesn't have definition.
a class is called abstract class only if it has at least one abstract method.
when you inherit a abstract class as a parent to the child class, the child class should define all the abstract method present in parent class.
if it is not done then child class also becomes abstract class automatically.
at last, python by default doesn't support abstract class and abstract method, so there is a package called ABC(abstract base classes) by which we can make a class or method abstract.

thisisdenish
Автор

for those who did not understand! assume a situation or an example (u r given a task to design some apps and an app to qualify it must and should contain some specific features like( brightness, notification ).so basically you can declare an abstract class with these feature declarations( brightness, notification ), but not the body in the abstract class and later u inherit them keeping in mind that while you are designing you must and should declare these feature's body for sure along with some more features and u might use the same abstract class for other app design because even it must also contain the specific features along with other, but the body declarations might change from class to class or an app to app if you are doing any real-time work).
hope u understood this

sujithkumar_ga
Автор

Essentially, you define abstract methods in an abstract class to ensure that it's child classes have a compulsion of having those methods defined inside them

prakhar
Автор

I see many are still confused with the concept and also with "how is it different from duck typing". Here is an example to get it cleared.

This is an exam 'hall' and there are students from 2 diffrent 'classes' seated. Class A has a maths test, Class B has social.

The invigilator says that to enter the hall, every one must carry an instrument box. Now students of classes both A and B must bring one even if B class don't have its use. So the class A will have a set of compass, rulers, pencils etc in it. But since students of class B don't have any use, they will just bring one with a pencil or even just empty (pass) because its compulsory to bring one in to be in the hall.

If a parent class has an abstract method, every child must also have one. So each child will have to define one of thier own.

In duck typing, It isn't necessary to define the parent class method for each child classes. it just simply have to point to the class where the particular method lies. Here we would have to define for each.

I hope this helps

ansafnisam
Автор

This video is quite confusing sir, can you please make one more so that we can understand this concept better.

sameernayak
Автор

no teacher teaches me that whiteboard example to explain the concept of abstraction, , your a genius sir..

tharunguduru
Автор

Sorry i cant understand very well what u said about when is useful to use an abstract classs only with abstract methods? can you answer me that please

alonsom.donayre
Автор

wonderful sir, great tutorial, thank you

malaygangulycodinghighway
Автор

Probably need more explanation about this topic. Why we need to create abstract classes. But among all of the youtube videos, this is much much better than others. Thank you...

md.anisurrahman
Автор

You just implemented the exact thing that my teacher taugh me in my Object Oriented Design lecture...
Thank you so much for the

dipenpandit
Автор

I am coding a sign language translation project. i am getting error "Process finished with exit code 134 (interrupted by signal 6: SIGABRT)". can you please help with this reply asap

azanhaider
Автор

How to create Final method in Python as I import typing module but it didn't work

gaurrahul
Автор

Sir this video is little confusing . I used computer inside whiteboard class then I should get the output right ? But I'm getting error that can't instantiate abstract calss whiteboard with abstract mathods process

tkishore
Автор

Thanks a lot sir...please complete data structures and algorithms with python...and if possible start machine learning/data science..as u were telling earlier u we're about to start ...

revolutionaryaihub-aonesto
Автор

At 9:51 my output comes only 'solving bugs'..that com.process is not executing..i dont understand what is happening and there is no error showing

ritikaagarwal
Автор

Many many thanks for posting the missed leathers of python. We are waiting for it👌👌👌👌😋😋

theprimordialdude
Автор

what is difference between interface and abstract class, getting confused on this abstract class and method concept

priyankachendekar
Автор

can you please help with practice problems to go through th concept abstract class

python_knooobb
Автор

Is this done to achieve abstraction from oops concept, please I need answer

exevil
Автор

Loved this video! Good explanation, good job.

superallipalli