Collections Module in Python
Get introduced to Python's collections module and its datatypes.
Python’s collections module has specialized container datatypes that can
be used to replace Python’s general-purpose containers (dict
, tuple
, list
, and set
). We will be studying the following parts of this module:
- ChainMap
- counter
- defaultdict
- deque
- namedtuple
- OrderedDict
There is a sub-module of collections called abc
or Abstract Base Classes
. These will not be covered in this chapter.
Let’s get started with the ChainMap
container!
Overview of ChainMap
A ChainMap
is a class that provides the ability to link multiple
mappings together such that they end up ...