What is Python Collections Module?

A collection in Python is a container data type. There are four main types: lists, tuples, sets, and dictionaries. Each has different properties based on the declaration, storage type, usage, etc. A container has data and an iterator too.

Besides these basic types, Python has additional containers with more specialized features in the Python collections module.

The new containers cover the shortcoming of the built-in data types. You must import the collection module into your program to use these data types. You do not need to install the collection module. It is already part of the programming language.

Following is the list of containers in the collection module.

  • nametuple
  • chainmap
  • deque
  • Counter
  • OrderedDict
  • defaultdict
  • UserDict
  • UserList
  • UserString