# Polymorphism

> One name that works on many kinds of thing, each doing it its own way.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Method Overriding, Duck Typing

## Think of it like

Think of it like saying speak to a dog and a cat. Each one answers in its own voice.

## Definition

Polymorphism means one name can work on many kinds of thing. Each kind does it its own way. You call area() on a circle and on a square, and each works out its own area. The code that calls it does not need to know which shape it has. Python's len works on text, lists and more for the same reason. It lets one loop handle a mix of objects.

## Example

Lucy's app keeps a list of shapes. One loop calls area() on each, and circles and squares each give the right answer.

## Example code

```python
>>> len("hi"), len([1, 2, 3])
(2, 3)
```

The same len works on text and on a list.

## Why it matters

It lets you add a new kind of thing without changing the code that uses it.

## Common mistake

Writing a long if chain that checks each type by hand. Let each class answer in its own way instead.

## Three principles

- **One name.** Many kinds of thing.
- **Each its own way.** The object decides.
- **Caller stays simple.** No type checks needed.

## Related terms

- [Inheritance](https://learn.benibix.com/term/development/inheritance)
- [Interface (Programming)](https://learn.benibix.com/term/development/interface)
- [Method (Programming)](https://learn.benibix.com/term/development/method)
- [Object-Oriented Programming (OOP)](https://learn.benibix.com/term/development/object-oriented-programming)

## Told apart from

- [Inheritance vs Polymorphism](https://learn.benibix.com/compare/inheritance-vs-polymorphism): People think inheritance and polymorphism are one idea. They are not, though they often show up together. Inheritance is how one class gets the parts of another. Polymorphism is one method name that does the right thing for each kind of object. Python can have it with no parent class at all. Each object just needs the method.

---

Source: https://learn.benibix.com/term/development/polymorphism
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
