Dunderless Python

This story is about improving your code quality and ways to reduce boilerplate when working with python. There are multiple options like using namedtuples, data classes, and Attrs. In this article, I will help you choose one!

Amine Kaabachi
6 min readNov 1, 2020
Photo by Magda Ehlers from Pexels

Dunderless Python = Python -Dunder Methods

We All Love Python

Python is one of the programming languages I use the most. I started using it mostly for CTFs (for the fantastic pwntools framework) and ended up using it whenever possible.

We all love Python, but even Python got some pitfalls.

Double underscore should be pronounced “dunder”. So __init__ is “dunder init dunder”, or just “dunder init”. — Ned Batchelder

The main issues I see with Python are:

  • When doing OOP, separating logic into multiple subclasses is very tedious as you need to make classes and define dunder methods for each of them. That usually pushed me away from applying SRP to gain time.
  • When you have complex data that need to be expressed, make the mistake of using the language…

--

--

Amine Kaabachi

Editor of Towards Data Mesh - Exploring Data Architecture and Best Practices