File:UML_class_pet.svg · Wikimedia Commons · See Wikimedia Commons
Also known as polymorphism (computer science), Polymorfism
concetto informatico

polymorphism | Python Glossary – Real Python
A concept in object-oriented programming (OOP) that allows objects of different classes to be treated the same if they share the same interface.
realpython.com →Polymorphism enables you to use a single interface to represent different underlying classes. In Python, polymorphism is achieved primarily through duck typing , but you can also implement it through inheritance and method overriding . Polymorphism enhances flexibility and maintainability by allowing you to write more generic and reusable code. class Duck: def swim(self): print("The duck is swimming.") class Albatross: def swim(self): print("The albatross is swimming.") The two classes don’t share a common base class . Because they share the same interface, you can still use them in the same way: from birds import Duck, Albatross birds = [Duck(), Albatross()] for bird in birds: ... bird.swim() ... The duck is swimming. The albatross is swimming. class Animal: def speak(self): print("Animal speaks") class Dog(Animal): def speak(self): print("Woof, Woof") class Cat(Animal): def speak(self): print("Meow, Meow") def make animal speak(animal): animal.speak() In this example, both Dog and Cat are subclasses of Animal and override the .speak() method. You can use instances of these classes the same way: The make animal speak() function demonstrates polymorphism by accepting any animal that inherits from Animal and calling its .speak() method, regardless of the specific type of animal. Learn how to define and use Python classes to implement object-oriented programming. Dive into attributes, methods, inheritance, and more.
Excerpt from a page describing this subject · 5,830 chars · not written by Vinony
In informatica, il termine polimorfismo (dal greco πολυμορφος composto dai termini πολυ molto e μορφή forma quindi "avere molte forme") viene usato in senso generico per riferirsi a espressioni che possono rappresentare valori di diversi tipi (dette espressioni polimorfiche). In un linguaggio non tipizzato, tutte le espressioni sono intrinsecamente polimorfiche. Il termine viene associato a due significati specifici: * nel contesto della programmazione orientata agli oggetti, si riferisce al fatto che un'espressione il cui tipo sia descritto da una classe A può assumere valori di un qualunque tipo descritto da una classe B sottoclasse di A (polimorfismo per inclusione); * nel contesto della programmazione generica, si riferisce al fatto che il codice del programma può ricevere un tipo come parametro invece che conoscerlo a priori (polimorfismo parametrico).
Abstract from DBpedia / Wikipedia · CC BY-SA
via Wikidata · CC0
via Wikidata sitelinks · CC0
Discovered by embedding cosine similarity (sentence-transformers MiniLM, 384-dim).