Python abstract classes 👻

  Рет қаралды 75,182

Bro Code

Bro Code

3 жыл бұрын

Python abstract class example tutorial explained
#python #abstract #classes
#abstract class = a class which contains one or more abstract methods.
#abstract method = a method that has a declaration but does not have an implementation.
prevents a user from creating an object of that class
+ compels a user to override abstract methods in a child class
from abc import ABC, abstractmethod
class Vehicle(ABC):
@abstractmethod
def go(self):
pass
@abstractmethod
def stop(self):
pass
class Car(Vehicle):
def go(self):
print("You drive the car")
def stop(self):
print("This car is stopped")
class Motorcycle(Vehicle):
def go(self):
print("You ride the motorcycle")
def stop(self):
print("This motorcycle is stopped")
#vehicle = Vehicle()
car = Car()
motorcycle = Motorcycle()
#vehicle.go()
car.go()
motorcycle.go()
#vehicle.stop()
car.stop()
motorcycle.stop()
music credits 🎼 :
===========================================================
Up In My Jam (All Of A Sudden) by - Kubbi / kubbi
Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
Free Download / Stream: bit.ly/2JnDfCE
Music promoted by Audio Library • Up In My Jam (All Of A...
===========================================================

Пікірлер: 152
@BroCodez
@BroCodez 3 жыл бұрын
TLDR # Prevents a user from creating an object of that class # + compels a user to override abstract methods in a child class # abstract class = a class which contains one or more abstract methods. # abstract method = a method that has a declaration but does not have an implementation. from abc import ABC, abstractmethod class Vehicle(ABC): @abstractmethod def go(self): pass @abstractmethod def stop(self): pass class Car(Vehicle): def go(self): print("You drive the car") def stop(self): print("This car is stopped") class Motorcycle(Vehicle): def go(self): print("You ride the motorcycle") def stop(self): print("This motorcycle is stopped") #vehicle = Vehicle() car = Car() motorcycle = Motorcycle() #vehicle.go() car.go() motorcycle.go() #vehicle.stop() car.stop() motorcycle.stop()
@Hazara_boy
@Hazara_boy 3 жыл бұрын
Thank you
@lovelyaashik9732
@lovelyaashik9732 2 жыл бұрын
Sir basically what's the use of it , for what. Purpose we're going to use it
@smaransure2234
@smaransure2234 Жыл бұрын
thanks
@christiangreyson115
@christiangreyson115 8 ай бұрын
p
@christiangreyson115
@christiangreyson115 8 ай бұрын
p
@shrikanthsingh8243
@shrikanthsingh8243 Жыл бұрын
Your intentions are clear - Simply educate and not show off smartness by complicating the content, which other channels do. Keep up your work.
@forrestelliott3267
@forrestelliott3267 2 жыл бұрын
This was really helpful, thank you. Though I think at 4:57 the error arose from the vehicle = Vehicle() line, not from the motorcycle = Motorcycle() line, as your commentary implies at that moment.
@yevhenliubarskyi1841
@yevhenliubarskyi1841 2 жыл бұрын
Thank you Bro, your explanations are just crystal clear. I've already watched several of your videos. Hope you achieve great success with your channel.
@guardmanbob
@guardmanbob 3 жыл бұрын
straight to the point, clear, and fun to watch. will binge all ur videos
@yuilhan4275
@yuilhan4275 3 жыл бұрын
Thank you, your explanations are clear and is easy enough to understand.
@trippingwithcrujo7708
@trippingwithcrujo7708 Жыл бұрын
Really simple and straight to the point. Makes it easier to understand more complicated applications later on. Good job!
@davidstefanov9210
@davidstefanov9210 3 жыл бұрын
Thank you for the video dude,It was very helpful and informative. BTW my Teacher linked this video in our Python course as a example
@roxykvarman8773
@roxykvarman8773 3 жыл бұрын
Thanks a lot! Great explanation! Subscribed and going to take your python and javascript crash courses!
@svensalvatore8702
@svensalvatore8702 Жыл бұрын
This is soo Good of a video and explanation. Thank you, sir!
@גייסוןחן
@גייסוןחן Ай бұрын
helped a lot on the basic understanding of the abstract class, which is exactly what I needed for my study, thank you! :)
@user-mq9hf1mm9f
@user-mq9hf1mm9f 4 ай бұрын
Omg, can I just say you are saving my life rn? Thank you for this clear and concise lesson - thank you SO much.
@otsapin
@otsapin 3 жыл бұрын
Great tutorial! Thanks a lot, bro! ;)
@linatroshka
@linatroshka Жыл бұрын
Very clear and concise explanation. Thank you very much for this!
@jackb4223
@jackb4223 3 жыл бұрын
Nice brief description of the essentials -- thanks!
@ravikanthduvvuri392
@ravikanthduvvuri392 2 жыл бұрын
I got best content thanks for your best class bro☺️☺️
@erickonyanda5570
@erickonyanda5570 3 жыл бұрын
Thank you very much. Wow!! Very simple, very easy, very clear explanation
@zacky7862
@zacky7862 2 жыл бұрын
Thanks. Finally I understand now the importance usage of abstract
@Muertedertod
@Muertedertod 2 жыл бұрын
finally someone that is able to explain this clear and short! THX a lot!
@simeonbogg3725
@simeonbogg3725 Жыл бұрын
Great explanation an example, very easy to understand!
@horoshuhin
@horoshuhin 2 жыл бұрын
this is such a concise and to-the-point explanation of ABC. I've yet to find a better one. and probably don't need to anyway. thank you
@RajatSadanandan
@RajatSadanandan 3 жыл бұрын
Really helpful! Thanks!!
@nishantrandev9633
@nishantrandev9633 2 жыл бұрын
Great video. To the point. That's how the content should be created. Thanks!
@stevechesney9334
@stevechesney9334 Жыл бұрын
Nice job! Easy to follow examples!
@liasantos6639
@liasantos6639 7 ай бұрын
Thank you for this video! Amazing explanation
@davidrowlands8548
@davidrowlands8548 2 жыл бұрын
Thank you I was able to understand this concept thanks to your video.
@Ronnie9P
@Ronnie9P 2 жыл бұрын
best explanation of abstraction in python on youtube
@d1jn
@d1jn 2 жыл бұрын
Great explanation bro! Thanks!
@sirenhanced6248
@sirenhanced6248 Жыл бұрын
Thanks so much I have a test for my Python OOP course tomorrow on this you saved me.
@macieks3604
@macieks3604 Жыл бұрын
Nicely explained! Thanks :)
@pablocesarlopez7379
@pablocesarlopez7379 Жыл бұрын
A very clear explanation. Thanks!
@hooman3669
@hooman3669 Ай бұрын
Loving these short conceptual videos 😁😁❤❤
@Techieinla
@Techieinla 3 жыл бұрын
very understandable
@nirutg5130
@nirutg5130 Жыл бұрын
I find 6-7 sources from internet to understand about Python abstraction but not understand!, just understand from this video. Thank you so much Bro.
@83sal
@83sal 3 жыл бұрын
Thank you sir!
@joelpaquete4152
@joelpaquete4152 Жыл бұрын
Thank you for this lessons
@cesarosantini708
@cesarosantini708 2 жыл бұрын
excellent explanation keep it up
@hrushikeshsahasrabuddhe5103
@hrushikeshsahasrabuddhe5103 8 ай бұрын
Simple & to the point!
@MrPimleemans
@MrPimleemans Жыл бұрын
Excellent explanation, thanks!
@SmokyDesperado91
@SmokyDesperado91 2 жыл бұрын
Thank you, great explanation! I have one question though: is there some way to create abstract attributes in analogy to abstract methods? I want to make sure that those attributes will be implemented in all child classes
@timhiggins7072
@timhiggins7072 9 ай бұрын
Bless you for making this more clear than my professor.
@akramal-fageeh8969
@akramal-fageeh8969 Ай бұрын
Really nice, concise, and clear
@Franco-ss4bu
@Franco-ss4bu 7 ай бұрын
I'm really liking your python tutorials
@softwareengineer8923
@softwareengineer8923 2 ай бұрын
Awesome tutorial, thanks
@theverynvg
@theverynvg Жыл бұрын
It's amazing!Thank you
@andrewv8350
@andrewv8350 2 сағат бұрын
Now, it's clear for me. Thanks a lot, bro!
@digosantista
@digosantista 2 жыл бұрын
Cool. But it would be nice to comment on the video (or do a voice over) to let people know that error arouse from Vehicle being instatiated not from implementation itself. Other than that, great! Thanks!
@beingzero7541
@beingzero7541 2 жыл бұрын
Wow!
@greenstreet704
@greenstreet704 Жыл бұрын
great video!!
@henriquefelinimena7433
@henriquefelinimena7433 3 жыл бұрын
Thank you Bro!
@reshmi003
@reshmi003 Жыл бұрын
Thanks alot ❤️
@sahilsagwekar
@sahilsagwekar Жыл бұрын
thanks bro
@anfedres
@anfedres 3 жыл бұрын
cool video bro... ps: Turn of the cc... it is hilarious!
@umarhasnain7369
@umarhasnain7369 3 жыл бұрын
Ya. Haha🤣.
@myoutube8832
@myoutube8832 4 ай бұрын
Great discussion Bro
@chriskeo392
@chriskeo392 Жыл бұрын
More content on abstraction and encapsulation while using dataclasses please
@Amirkolo
@Amirkolo 5 ай бұрын
you are a genius bro. thanks 🙂
@abdullahnasir8535
@abdullahnasir8535 9 ай бұрын
You are just amazing bro
@SuccessXcel_
@SuccessXcel_ 11 ай бұрын
Best explanation.
@soklin
@soklin Жыл бұрын
Thank you!!!
@fellowstepchicken7555
@fellowstepchicken7555 7 ай бұрын
Thanks bud !
@igordjokic
@igordjokic Жыл бұрын
NIce!
@kemann3815
@kemann3815 2 жыл бұрын
Lovely
@user-yu1dc7su2r
@user-yu1dc7su2r 10 ай бұрын
Thanks alot.🙏
@tarikyassa1076
@tarikyassa1076 3 жыл бұрын
Thanks Bro!
@chillydoog
@chillydoog 9 ай бұрын
for the algorithms. ty brother
@priyanshagarwal1565
@priyanshagarwal1565 4 ай бұрын
You teach nice
@kerry7932
@kerry7932 8 ай бұрын
Nice video. I think we need some additional information about the purpose of abstract classes as many of the comments have indicated. That is, is if subclasses cannot inherit from their parent, what is the purpose of the parent?
@hiiexisthiiexist1284
@hiiexisthiiexist1284 Жыл бұрын
awesome video
@EissaAlahdul
@EissaAlahdul Жыл бұрын
Thanks!
@woltron4o
@woltron4o 2 жыл бұрын
Very nice and useful video
@hangchen
@hangchen 9 ай бұрын
Thx bro!
@harithabandara3212
@harithabandara3212 Жыл бұрын
Thank youu!!!
@streamindigoflags8035
@streamindigoflags8035 10 ай бұрын
Hi bro nice video
@cloudroot7
@cloudroot7 Жыл бұрын
It's easy to understand the concept.
@jhontriboyke5534
@jhontriboyke5534 4 ай бұрын
thank you bro !
@shavindasilva
@shavindasilva 2 жыл бұрын
best BRO :)
@pun15h3r.
@pun15h3r. 3 ай бұрын
quick and dirty. nice, thanks!
@TheHansdampf80
@TheHansdampf80 6 ай бұрын
Thank you
@marianotorres4052
@marianotorres4052 Жыл бұрын
thank you!
@lovelyaashik9732
@lovelyaashik9732 2 жыл бұрын
Sir basically what's the use of it , for what. Purpose we're going to use it
@omercagla8970
@omercagla8970 Жыл бұрын
Best tutorial I have ever seen
@santosbogo
@santosbogo Жыл бұрын
I am doing python at university and this is the best video Ive ever watch
@user-cd4zb3gk3z
@user-cd4zb3gk3z Ай бұрын
Спасибо, видео помогло разобраться!
@sterlingevans129
@sterlingevans129 Жыл бұрын
Can someone explain the reason an abstract class would be needed if the child class' methods would be explicitly written anyway?
@HussainAli-sb1dv
@HussainAli-sb1dv 9 ай бұрын
love u
@lw9954
@lw9954 Жыл бұрын
ty bro
@user-ew7ri4gk2l
@user-ew7ri4gk2l 3 ай бұрын
You are very clear and objective. But I can't understand the use of abstract class if you can't instantiate it and the same functions are written bellow in other classes??? Thanks in advance.
@xBaphometHx
@xBaphometHx Жыл бұрын
Clear as water!!!
@Vertig_Pro
@Vertig_Pro Жыл бұрын
Keep doing gods work bro
@rubenc4696
@rubenc4696 3 ай бұрын
Thanks
@uuhju7004
@uuhju7004 3 жыл бұрын
nice
@jimenadelgado7384
@jimenadelgado7384 3 ай бұрын
thaaaanks
@gattinocurioso6852
@gattinocurioso6852 9 ай бұрын
In python can you explain the difference from Abstract class and Interface?
@nazarsilchenko8326
@nazarsilchenko8326 2 жыл бұрын
Instant like for mentioning the need for speed:)
@joetaff5960
@joetaff5960 2 жыл бұрын
great explanations but how is this actually used in a real world situation? I assume this would be a tiny chunk of massive code. I've watched all 47 videos up to this point and understand them all but rarely do they truly build on each other as a whole. I hope the rest of the programs in the latter half solve this issue.
@shingaling3315
@shingaling3315 11 ай бұрын
I understand the implementation but what is the purpose of doing this? I’m not following what benefit was gained by going through this versus not defining an abstract class at all
@WaldoTheWombat
@WaldoTheWombat Жыл бұрын
What about abstract functions? If I go into the print function, i end up at the builtins file which has many functions that just have "pass" inside them. What is that about?
@vitaliytysiachnyk5347
@vitaliytysiachnyk5347 11 ай бұрын
Bro, please add English subtitles, because it's only Vietnam. Lol Thank you!
@MystikPrae
@MystikPrae Жыл бұрын
from abc import ABC,abstractmethod class Animal(ABC): @abstractmethod def eat(self): print("This is eating something") class Rabbit(Animal): def eat(self): print("This is eating grass") obj=Rabbit() obj.eat()
@samiam.402
@samiam.402 2 жыл бұрын
I might've missed it, did he explain why you don't have to "super()" the methods you are overriding? Is this an inherent part of an abstract class, or am I missing something?
@Craulback
@Craulback 2 жыл бұрын
super() gets the child class access to the attributes from the parents method, it doesn't override anything, but is useful when your child class needs the same attributes, plus some new one. class Child(Parent) def __init__(self,attribute_1,attribute_2,attribute_3) super().__init__(attribute_1,attribute_2) # this will pull the first 2 attributes (of the same name) from the parent as for overriding, just defining the child's method using the same name as the one in the parent will override it for the child class. it looks for the "go()" method in the child class, before looking for the one from the parent. so it never actually encounters the abstract version of the method.
@sebastianradlmeier8922
@sebastianradlmeier8922 2 жыл бұрын
​@@Craulback Thanks for the explanation
Metaclasses in Python
15:45
mCoding
Рет қаралды 151 М.
Python Object Oriented Programming in 10 minutes 🐍
10:04
Bro Code
Рет қаралды 367 М.
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,6 МЛН
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 37 МЛН
Abstract Classes and Methods in Java Explained in 7 Minutes
7:00
Coding with John
Рет қаралды 496 М.
Python inheritance 👪
7:19
Bro Code
Рет қаралды 78 М.
Protocol Or ABC In Python - When to Use Which One?
23:45
ArjanCodes
Рет қаралды 199 М.
Python multithreading 🧵
13:34
Bro Code
Рет қаралды 63 М.
SUPER() in Python explained! 🔴
13:06
Bro Code
Рет қаралды 4,9 М.
Python staticmethod and classmethod
7:35
mCoding
Рет қаралды 113 М.
Python Data Classes Are AMAZING! Here's Why
16:11
Tech With Tim
Рет қаралды 74 М.
Python lambda λ
5:21
Bro Code
Рет қаралды 36 М.
Let's code a SNAKE GAME in python! 🐍
33:06
Bro Code
Рет қаралды 585 М.
Как бесплатно замутить iphone 15 pro max
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
Looks very comfortable. #leddisplay #ledscreen #ledwall #eagerled
0:19
LED Screen Factory-EagerLED
Рет қаралды 6 МЛН
Опасность фирменной зарядки Apple
0:57
SuperCrastan
Рет қаралды 10 МЛН
Новые iPhone 16 и 16 Pro Max
0:42
Romancev768
Рет қаралды 2,1 МЛН