Python Collections Module
Published Jul 7, 2022
Contribute to Docs
Collections Module
- ChainMap
- Creates a single view of multiple dictionaries or mappings in Python.
- collections.Counter
- A dict subclass that stores counts for hashable objects.
- defaultdict
- Creates a dictionary-like object that provides default values for missing keys.
- deque()
- Creates a deque object.
- namedtuple
- Creates tuple subclasses with named fields for improved code readability in Python namedtuple structures.
- OrderedDict
- Maintains the order in which keys were inserted in a dictionary.
- UserDict
- A wrapper class from collections that allows creating customized dictionary-like objects by subclassing it instead of dict.
- UserList
- Wrapper around list objects for easier list subclassing.
- UserString
- A wrapper class for string objects that makes subclassing easier.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
- With Certificate
- Beginner Friendly.24 hours