mathspp blog

417 447,116 37,707
articles words lines of code

Today I learned that you can dynamically change the type of an object in Python.

The dunder method __new__ is used to customise object creation and is a core stepping stone in understanding metaprogramming in Python.

This article shows how you can create a case-insensitive string class using some basic meta programming with the dunder method __new__.

Descriptors are not black magic and this article will show you that. In fact, you use descriptors every day and you don't even know it.

Learn how to use properties to add dynamic behaviour to your attributes.

How do you implement a case-insensitive (or caseless) dictionary? In this article we explore solutions where we inherit from the built-in dict, the abstract base class MutableMapping from the standard module collections.abc, and the UserDict in the standard module collections.