why do we always write (self) after every magic function? what is its purpose?
Doubt in dunders or magic function
Hello @vanshikasetia, self means that the object itself. So my using self we access that particular class objects in which we are writing.
Suppose you have a class and it has an attribute name. Now with self, you can use this attribute inside any function of the class. Like self.name can be used in any function.
I hope it is clear to you. In case there is any confusion pls feel free to ask it.
In case it is clear to you, pls mark it as resolve and feel free to provide the feedback.
Thanks
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.