collections module
The standard library module of extra container types, including Counter, defaultdict, namedtuple and deque.
In more detail
namedtuple makes a lightweight record type whose fields have names as well as positions, and deque is a list optimised for adding and removing at both ends. Counter and defaultdict are the two you will use most.
Related terms
- Counter — A dictionary from the collections module that counts how many times each item occurs.
- defaultdict — A dictionary from the collections module that creates a default value, such as an empty list, the first time a missing key is used.
- tuple — An ordered, fixed-length group of values in which each position can have its own meaning and type.
Taught in
- A Standard Library Tour — Hands-on Python: Complete Video Course & Book