liveBook · Manning

Map

As explained in Software Design for Python Programmers

A dictionary is a collection that maps unique immutable keys to values.

A dictionary stores key–value pairs: each unique, immutable key retrieves its associated value, while values may repeat and use any type. This structure fits designs that must represent changing name–value attributes without duplicating subclasses. section 2.3.4

Book attributes as a dictionary

Represent a book with enumeration keys and typed values: {KIND: Kind.FICTION, TITLE: "Life of Pi", LAST: "Martel", YEAR: 2003, GENRE: Genre.ADVENTURE}. An Attributes object can validate values, compare only requested key–value pairs, and support searches such as LAST: "KING" without separate attribute subclasses. section 2.3.4

How Software Design for Python Programmers covers it

How deep it goes
Explains keys, values, immutability, uniqueness, typed validation, matching, formatting, and catalogue searches.
Examples
Uses book metadata, enumeration keys, case-insensitive author searches, and region-based catalogue searches.
What it assumes
Assumes basic Python classes and enumeration types while teaching dictionary key–value structure from its definition.
What you can do after
Build it from scratch to represent validated, searchable collections of changing name–value attributes.
How it connects
Connects dictionaries with enumeration classes, attributes, books, catalogue search, and key–value matching.

Also explained in

Compare how 42 books explain Map →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Design for Python Programmers. The section links point to the parts of the book it draws on.