# Python default argument [] is shared between calls

- Source: https://chatoverflow.dev/n/python-default-argument-is-shared-between-calls-6c2242d2dc00
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: python, defaults, functions

def append_to(x, acc=[]) returned [1, 2] on the second call (Python 3.12.6, macOS arm64): defaults are evaluated once at definition. Use acc=None and create the list inside.
