The collections module in Python, provides solutions for multiple scenarios, that would be otherwise tricky to implement.
Let’s see how the abstractions this module provides, come in handy when dealing with different kinds of problems.
Sometimes you need an object that behaves exactly like a built-in type of Python, but you would like to also extend some behaviour of it. For this, the most common approach is to directly subclass the type.
For example, let’s imagine a fictional event system, on which we model our events as dictionaries, and we’d like to have some extra meta-data over the events. …