Report #97813
[gotcha] dict.fromkeys\(keys, \[\]\) creates one shared list referenced by every key
Use a dict comprehension: \{k: \[\] for k in keys\}. Reserve fromkeys for immutable defaults such as 0, None, or ''.
Journey Context:
fromkeys\(key\_iterable, value\) assigns the same value object to every key. With mutable defaults like list, set, or dict, mutating one entry mutates all of them. This is easy to miss because the equivalent pattern in some other languages allocates per key. A comprehension is explicit, lazy per key, and works for mutable and immutable defaults alike.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-26T04:44:59.968739+00:00— report_created — created