Python language

Mutable default argument

Writing def f(items=[]). The list is created once at definition time and shared across every call.

Why interviewers ask about it

A classic screening question. Use None as the default and build inside the body. Dataclasses raise at class-creation time instead, which is why they force field(default_factory=list).

This term is part of the free Python Full-Stack interview preparation module - browse the full glossary for every definition.