Python Collections Module (9 Part Series)
1 Python’s Collections Module: Introduction
2 Python’s Collections Module: Counter
… 5 more parts…
3 Python’s Collections Module: Why dictionaries maintain insertion order but printing Counter doesn’t?
4 Python’s Collections Module: OrderedCounter
5 Python’s Collections Module: OrderdDict
6 Python’s Collections Module: defaultdict
7 Python’s Collections Module: namedtuple
8 Python’s Collections Module: deque
9 Python Collections: Hackerrank Question on Counter
Introduction
This module implements specialized container datatypes providing alternatives to Python’s 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,
Name | Purpose |
---|---|
Counter | dict subclass for counting hashable objects |
OrderedDict | dict subclass that remembers the order entries were added |
defaultdict | dict subclass that calls a factory function to supply missing values |
deque | list-like container with fast appends and pops on either end |
namedtuple | factory 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 !
Python Collections Module (9 Part Series)
1 Python’s Collections Module: Introduction
2 Python’s Collections Module: Counter
… 5 more parts…
3 Python’s Collections Module: Why dictionaries maintain insertion order but printing Counter doesn’t?
4 Python’s Collections Module: OrderedCounter
5 Python’s Collections Module: OrderdDict
6 Python’s Collections Module: defaultdict
7 Python’s Collections Module: namedtuple
8 Python’s Collections Module: deque
9 Python Collections: Hackerrank Question on Counter
暂无评论内容