In pattern matching, a mapping is defined as one of the following:
a class that inherits from
collections.abc.Mapping
a Python class that has been registered as
collections.abc.Mapping
a builtin class that has its (CPython)
Py_TPFLAGS_MAPPING
bit set
a class that inherits from any of the above
The standard library classes
dict
and
types.MappingProxyType
are mappings.
A string literal appearing as the first statement in the function body is transformed into the function’s
__doc__
attribute and therefore the function’s
docstring
.
A string literal appearing as the first statement in the class body is transformed into the namespace’s
__doc__
item and therefore the class’s
docstring
.