# Duck Typing

say it: **“DUK TYPE-ing”** **/ˈdʌk ˈtaɪpɪŋ/**

Python cares what an object can do, not what class it is.

## What is **duck typing**?

**Duck typing** means Python cares what an object can do, not what class it is: "if it walks like a duck and quacks like a duck, it's a duck".

```python
class Printer:
    def write(self, text):
        print(text)

def save_report(output):
    output.write("Monthly sales: $12,400")   # anything with write() works

save_report(Printer())
save_report(open("report.txt", "w"))
```

Level: Freelancer · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=4)

Updated: November 17, 2026

Source: https://www.ask-codey.com/glossary/duck-typing
