By inheriting from Mapping we mix in the full mapping behavior, .e.g. .get()
and .key() methods. This is to make these collections feel more pythonic.
Additionally, it's a real usability improvement: e.g. for SlidePlaceholders
one cannot guess the valid keys, which makes placeholders[idx] difficult to use.
Having placeholders.keys() available makes inspection much easier.
Both are essentially mappings and define the minimal interface for
collections.abc.Mapping
(https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes), i.e.__iter__
,__getitem__
and__len__
.By inheriting from
Mapping
we mix in the full mapping behavior, .e.g..get()
and.key()
methods. This is to make these collections feel more pythonic. Additionally, it's a real usability improvement: e.g. forSlidePlaceholders
one cannot guess the valid keys, which makesplaceholders[idx]
difficult to use. Havingplaceholders.keys()
available makes inspection much easier.