Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 13, 2021 06:12 am GMT

Python's Collection Module: Introduction

Introduction

This module implements specialized container datatypes providing alternatives to Pythons general purpose built-in containers, dict, list, set, and tuple.

What types does it offer?

Following are the most commonly used special container types of collections module,

NamePurpose
Counterdict subclass for counting hashable objects
OrderedDictdict subclass that remembers the order entries were added
defaultdictdict subclass that calls a factory function to supply missing values
dequelist-like container with fast appends and pops on either end
namedtuplefactory function for creating tuple subclasses with named fields

And...

We can also implement a custom container type like OrderedCounter using the container types provided by collections module.

The next series of posts will dive deep into the above mentioned container types provided by collections module.

Stay Tuned !


Original Link: https://dev.to/kathanvakharia/python-s-collection-module-introduction-4c4b

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To