I know dictionaries, but what is a DefaultDict?

The supporting repository and code file is: https://github.com/StatsGary/PyHacks-Tutorials/blob/main/28_defaultdict.py. This is aimed as a short article to explain why you would want to use default dictionaries. What is a defaultdict I hear you ask? A defaultdict is a container like dictionary present in the collections module. The functionality of both dictionaries and defaultdict is most the…

Continue Reading

Narly NamedTuples in Python

NamedTuples are an excellent way to make your Python code more useful and readable. In short a NamedTuple is an alternative to the built-in tuple . This extension type enhances standard tuples so that their elements can be accessed by both their attribute name and the positional index. This is really powerful, as you can then refer…

Continue Reading