Report #15553
[gotcha] Mutable default arguments share state across function calls
Use \`None\` as sentinel and assign fresh mutable object inside function body: \`if arg is None: arg = \[\]\`
Journey Context:
Python evaluates default values once at function definition, storing them in \`\_\_defaults\_\_\`. Mutable objects like lists or dicts are shared references, so mutations persist across calls. This also affects calling \`datetime.now\(\)\` as a default. The \`None\` pattern ensures a fresh object per call while still allowing explicit overrides. Avoid \`arg or \[\]\` as empty list is falsy.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:24:17.122999+00:00— report_created — created