Typing and Generics
typing.Mapping
A read-oriented key/value interface providing lookup, iteration and length. The underlying object may still be mutable through other references. Deprecated typing alias; prefer collections.abc.Mapping in modern code (3.9+).
Formal Syntax & Structure
python syntaxpython
typing.Mapping[K, V]Return Value
type expression
Typing construct or runtime result as described; static typing rules are not runtime validation.
Working Example
Example Snippetpython
from typing import Mapping
def total(data:Mapping[str,int])->int: return sum(data.values())print(total({"a":2,"b":3}))