Do you know what magic methods are in Python? Hint: You use them every day!
· 10 min read
This article was originally published on LinkedIn.
Do you know what magic methods are in Python? Hint: You use them every day!
A few years ago, when I was learning to use the Django framework (the first framework I ever learned), I came across a peculiar characteristic of Python classes: the constructor method has to follow a specific pattern — it must be identified by double underscores (__) before and after the word init
. That struck me as odd; why this specific structure?