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.
Python does not support method overloading. The syntax don't. Methods with the same name under a class will only retain the last method definition. But they have something to make up for it such as manipulating Default Parameters and Keyword Arguments and Factory Functions (basically instantiating objects via function)
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.
u r awesome. u make it so simple to use one example and it's works for Polymorphism, Inheritance , Abstraction.....He is expert, who can make critical things easy.
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!
but what's the whole point of it? i mean i could simply just override the method say_hello() by adding it with same name in the child class without any inheritance! and if it's not there, an error would say simply that the class has no such an attribute! will this still be called Polymorphism?
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()
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.
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
It’s not really complex, poly means many and morphism means having different form. These are suffix/prefix taught in middle or highschool depending on where you went. ‘Polygon’ - having many sides ‘Polysyllabic’ - many syllables And more but yeah
Remember to always break down a word see if it has any familiar prefix or suffix, we tend to over look them and look at the word as whole a lot of times
It's "Ni Hao" not "Yeehaw" haha
XD
LOL
LMAO
so, peter griffin was right :P
lmao i was thinking the same thing. Made me laugh
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.
Python does not support method overloading. The syntax don't. Methods with the same name under a class will only retain the last method definition. But they have something to make up for it such as manipulating Default Parameters and Keyword Arguments and Factory Functions (basically instantiating objects via function)
When you say "ee-haw" so cute. Great vid :)
Thanks, the concept is clear.
It really helps !
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
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.
Thanks from Argentina!
nice.. so easily expalined. thanks
Thanks a lot
Good explanation
Bro super ah explain paninga...apdiya python hierarchical inheritance pathi video make panni poduga bro...
u r awesome. u make it so simple to use one example and it's works for Polymorphism, Inheritance , Abstraction.....He is expert, who can make critical things easy.
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!
thanks 🙂
You're welcome!
but what's the whole point of it? i mean i could simply just override the method say_hello() by adding it with same name in the child class without any inheritance! and if it's not there, an error would say simply that the class has no such an attribute! will this still be called Polymorphism?
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()
thanks
I was watching the video and all of a sudden my name appeared and I'm like waittt whattttttt😂😂
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.
Sorry, bro I didn't use WordPress.
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
gj . could you explain this in laravel eloquent ?
Hmmmm you are right. I will try to explain this on laravel level also
@@Bitfumes tnx dude
Why they give such simple topics such complex names?
It’s not really complex, poly means many and morphism means having different form. These are suffix/prefix taught in middle or highschool depending on where you went.
‘Polygon’ - having many sides
‘Polysyllabic’ - many syllables
And more but yeah
Remember to always break down a word see if it has any familiar prefix or suffix, we tend to over look them and look at the word as whole a lot of times
Ni hao
This information is not correct completely.
hey, thanks for this, please tell me what else needs to implement
😵
did you liked it
Hard to understand
no sense
lol yeehaw xD
Fita mu
This don’t make any sense bruh 😂
Don't drag and brag while talking. Speak normally