The Magic of Self: How Python inserts self into methods by Sebastiaan Zeeff | PyConSe | 2025
Chances are that you’ve noticed that Python magically inserts “self” into methods for you. What you might not know is that the power behind this magic is the well-defined descriptor protocol. In fact, descriptors power many of the magical things in Python, from simple properties to lazy-loading attributes on database models. In this talk, I will explain the magic of self by introducing you to the descriptor protocol. I will show you how this protocol powers the insertion of self and what else you can do with it. By the end, you will have a solid understanding of descriptors and know enough to start implementing descriptors of your own. #pyconse #pyconse2025 #stockholm