Do you know about the Magic Methods in Python?
In my last post , I talked about Object-Oriented Programming(OOP). And I specifically talked about a single magic method __init__
which is also called as a constructor method in the OOP terminology.
The magic part of __init__
is that it gets called whenever an object is created automatically. But it is not the only one in any sense. Python provides us with many other magic methods that we end up using without even knowing about them. Ever used len()
, print()
or the []
operator on a list? You have been using Dunder methods.
In this post, I would talk about five of the most used magic functions or “Dunder” methods.
Keep reading with a 7-day free trial
Subscribe to MLWhiz | AI Unwrapped to keep reading this post and get 7 days of free access to the full post archives.