Skip to content

Glossary: Python Beyond the Basics

mutable default trap

Also written: mutable default argument

A bug where a list or dict used as a default parameter value is created once and shared by every call. Fix it by defaulting to `None` and creating a fresh list inside the function.

Where the book teaches it

Related terms

mutable / immutabledataclass