Polymorphism (OO Python Tutorials)

Publicado em: 26 Novembro 2023
no canal de: Andy Dolinski
526
5

Lesson 04 - Polymorphism is a concept in object-oriented programming that allows an object to have different behaviours depending on the context. It means that the same name or symbol can have different meanings or implementations for different types of objects.

For example, in Python, the + operator can perform different operations depending on the types of the operands. It can mean addition for numbers, concatenation for strings, or union for sets. This is an example of polymorphism, because the same operator can have different meanings for different types of data.

Another example of polymorphism in Python is the use of inheritance and overriding. Inheritance is a mechanism that allows a child class to inherit the attributes and methods from a parent class. Overriding is a way of modifying or extending the behaviour of a parent class by redefining a method in the child class. For example, if you have a class called Animal that has a method called sound that returns the sound of the animal, and you have a subclass called Dog that inherits from Animal and overrides the sound method to return "woof", then you can use a Dog object as an Animal object, and it will use its own sound method instead of the parent class sound method. This is an example of polymorphism, because the same method name sound can have different implementations depending on the type of the object.

Polymorphism allows you to write generic and flexible code that can work with different types of objects, as long as they have the same interface or methods. It also helps you to model real-world entities and systems in a natural and intuitive way.

In this video tutorial, I am going to show you how to use multipledispatch and also default values to achieve the same outcomes.

If you want to learn more about polymorphism in Python, you can check out the following resources:

[Python Polymorphism - W3Schools](^1^)
[Polymorphism in Python - GeeksforGeeks](^2^)
[Polymorphism in Python with Examples | Scaler Topics](^3^)
[What is Polymorphism in Python? - Educative](^4^)
[Polymorphism in Python with EXAMPLES - Guru99](^5^)

Source: Conversation with Bing, 26/11/2023
(1) Python Polymorphism - W3Schools. https://www.w3schools.com/PYTHON/pyth....
(2) Polymorphism in Python - GeeksforGeeks. https://www.geeksforgeeks.org/polymor....
(3) Polymorphism in Python with Examples | Scaler Topics. https://www.scaler.com/topics/python/....
(4) What is Polymorphism in Python? - Educative. https://www.educative.io/blog/what-is....
(5) Polymorphism in Python with EXAMPLES - Guru99. https://www.guru99.com/polymorphism-i....


Nesta página do site você pode assistir ao vídeo on-line Polymorphism (OO Python Tutorials) duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Andy Dolinski 26 Novembro 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 526 vezes e gostou 5 espectadores. Boa visualização!