Answer the question
In order to leave comments, you need to log in
Is there polymorphism in dynamically typed languages?
Is there polymorphism in python language?
If so, how is it expressed?
On the example of languages with static typing, it is clear why it is needed.
Answer the question
In order to leave comments, you need to log in
Polymorphism is the ability of objects with the same specification to have different implementations.
>>> class SomeClass:
... def __init__(self, x):
... self.x = x
... def __sub__(self, other):
... return self.x + other.x
...
>>> sc1 = SomeClass(10)
>>> sc2 = SomeClass(5)
>>> sc1 - sc2
15
Polymorphism - refers to the basic features of OOP. That is, the ability to view objects through the prism of the basic interface.
Typing is usually a property of the compiler (or runtime) to determine the type inference of each variable.
These are two different axes of measurements in general. The square is essentially h 4 cells. Whether there is polymorphism or not. And static type or dynamic.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question