Have you ever wondered how Python makes objects work with operators like + or -? Or how it knows how to display objects when you print them? The answer lies in Python's magic methods, also known as dunder (double under) methods. Magic methods are spe...
This write up deals with exploring the object creation aspect in Python. Specifically, it attempts to answer following queries: How are Python objects created? How can we change that for special use cases? What magic takes place in this process? W...
Understanding Magic Methods in Python Magic methods in Python, also known as dunder methods (because they have double underscores at the beginning and end of their names), allow us to define the behavior of our objects for various operations. They en...
Imagine you've built this cool bit of logic that relies on using a Set of objects. You've written the class yourself, and now you're passing objects into a set like so. class CleverClass: def __init__(self, name: str, data: dict[str, bool]) -> No...