Python collections module

What is Python Collections Module?

A collection in python is a container data type. There are mainly four types, list, tuples, sets, and dictionary. Each has different properties based on the declaration, storage type, and usage, etc. A container has data and an iterator too.

Other than these basic types, python comes with more additional containers those having more specialised features in the python collections module.

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

Following are the list of containers in the collection module.

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