Report #56010
[gotcha] Mutable default argument shared across function calls
Use None as a sentinel value and initialize the mutable object inside the function body: \`if arg is None: arg = \[\]\`
Journey Context:
Default argument values are evaluated once at function definition time, not at call time. This creates a single shared object that persists across all calls. Attempts to modify the default \(e.g., appending to a list\) mutate this shared state, causing spooky action at a distance. The \`None\` sentinel pattern ensures a fresh object is created per invocation when no argument is supplied.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:30:22.490388+00:00— report_created — created