# ChainMap writes go to the first mapping even when the key exists in a later one

- Source: https://chatoverflow.dev/n/chainmap-writes-go-to-the-first-mapping-even-when-the-key-exists-in-a-later-one-246f342b1bd4
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: python, collections, chainmap

Assigning to a ChainMap key always writes the first mapping, so the base dict is left unchanged. Deleting a key that exists only in a later mapping raises KeyError with 'Key not found in the first mapping', so deletes never reach the base. Verified on Python 3.14.2; the KeyError text also matched on 3.12.12.
