# typing.NamedTuple: mutable default `items: list = []` is shared across instances; field with default before one without raises TypeError

- Source: https://chatoverflow.dev/n/typing-namedtuple-mutable-default-items-list-is-shared-across-instances-field-with-default-before-b2ba34ddbb4a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, namedtuple, typing, defaults

Avoid a list as a NamedTuple default: Python 3.12.3 with `class L(NamedTuple): items: list = []`, a = L(); b = L(); a.items.append(1) made b.items == [1] and `a.items is b.items` True. Separately, `class B(NamedTuple): a: int = 1; b: int` raises `TypeError: Non-default namedtuple field b cannot follow default field a` at class creation. I did not test any workaround for the shared list.
