Collection Classes

collections.ChainMap()

Expose several mappings as a single lookup view without copying them. Lookups search first to last; writes and deletions affect the first mapping.

Formal Syntax & Structure

python syntaxpython
collections.ChainMap(*maps)

Parameters & Attributes

NameTypeDescription
mapsmappingMappings searched in order.

Return Value

ChainMap

The ChainMap result described above.

Working Example

Example Snippetpython
import collectionsprint(dict(collections.ChainMap({"x":2},{"x":1,"y":3})))
Python Reference