Python - Object Oriented Programming | Polymorphism

preview_player
Показать описание
Python Polymorphism and abstract classes
Python Object Oriented Programming, Python OOP concepts
What is Polymorphism in Python and how it is helpful

--You May Also Like --

==================FOLLOW ME ==================

Subscribe for New Releases!

(ask me questions!)

--- QUESTIONS? ---

Leave a comment below and I or someone else can help you.
For quick questions you may also want to ask me on Twitter, I respond almost immediately.

Thanks for all your support!
Рекомендации по теме
Комментарии
Автор

It's "Ni Hao" not "Yeehaw" haha

cristopher
Автор

Hey there, thanks for the video. I think it would be good to also point out what advantages polymorphism provides. In your example, it just adds more stuff to an already working piece of code ;-) But again, thank you for putting in the time to make this video. It is an easy-to-understand example of the "how" of polymorphism.

sebastiannachtigall
Автор

This is a great video, i learnt polymorphim and i almost forgot it, this video gave me a quick revision of polymorphism, thank you Sarthak sir

shaanlashkari
Автор

When you say "ee-haw" so cute. Great vid :)

barrydevine
Автор

Thanks, the concept is clear.
It really helps !

lwmrvmb
Автор

Thanks for trying but seems that any explanation I can find is incomplete or confusing. In this case you showed (if I am not wrong):
1)"polymorphism as "duck typing": you have two classes with no hereditary relationship amongst them, which simply have methods with exactly the same name.
2) "polymorphism as overriding": you have one class that inherits annother class (in your example class French inherits class Language ....and as second example class Chinese also inherits class Language), and the "son" class (the class that inherits annother class) has a method with the same name as the parent class (method "say_hello" ) and so it happens that the program will execute the method as defined in the son class, because it is more specific, which means that you can use one same method name ("say_hello") and obtain two different results depending on which code it runs: the code of the parent class or the code of the son class.

*According to books and videos about JAVA (don`t know if this is posible in Python too, but is useful to know) there is annother type of polymorphim called "method overloading" where you simply create two or more methods with the same name inside a class, but each of those methods has different types of parameters it can recieve, so depending on which type of parameters it recieves from the object that calls the method, one version of the method or annother different one will be executed.

Cssaarr
Автор

Is polymorphism the idea that you can have different children from the same parent class? Also, I really like the way you created the "abstract class" in the parent class without having to use the ABC module - just raise an error when it is called!

kaushikdr
Автор

u r awesome. u make it so simple to use one example and it's works for Polymorphism, Inheritance, is expert, who can make critical things easy.

sabbirahamed
Автор

Bro super ah explain paninga...apdiya python hierarchical inheritance pathi video make panni poduga bro...

kathiresan.r
Автор

This is an important topic that
How to use Laravel with WordPress to customize our 3project and theme and develop own API.

It'll help for all Laravel and wp developers.
Plz make a video or article about it

sorry for the comment about it in here!
Thanks so much.

eejazishaq
Автор

I was watching the video and all of a sudden my name appeared and I'm like waittt

sarthaknimbalkar
Автор

Why they give such simple topics such complex names?

-_______________________.___
Автор

Thanks for the video.... sorry, this is NOT polymorphism, this is about typecasting.
Polymorphism is a different mechanism and can't be implemented in Python due to Python's nature being dynamic-typed languge

ShukyPersky
Автор

gj . could you explain this in laravel eloquent ?

opentech
Автор

This information is not correct completely.

KaushikSarkar
Автор

Don't drag and brag while talking. Speak normally

pavinkumarr
Автор

to better understand the use of it

class Language():
def speak(self):
print("Universal answer HELLO")
#raise NotImplementedError("Support but need to be implemented in child!")

class Portuguese(Language):
def speak(self):
print("oi")

class Spanish(Language):
pass #WE NEED MORE DEVELOPERS RIGHT NOW

def main():
print("started")

newLang = Portuguese()
newLang.speak()

moreLang = Spanish()
moreLang.speak()

if __name__ == "__main__":
main()

jvcss