What is the purpose of magic methods whether I can do the same work by using regular codes? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the purpose of magic methods whether I can do the same work by using regular codes?

14th Feb 2018, 9:02 PM
Azazul Islam
Azazul Islam - avatar
3 Answers
+ 1
Magic methods can be accessed by operators such as + Instead of needing to call the method: obj1.add(obj2) You can simply: obj1 = obj1 + obj2
14th Feb 2018, 9:44 PM
Julián González Calderón
Julián González Calderón - avatar
+ 1
It is easier to read and understand and is less verbose and doesn't populate as much the class methods.
15th Feb 2018, 8:57 AM
spcan
spcan - avatar
0
I understand that.But why I need to do so as I can easily perform the same work by using structured programming?
15th Feb 2018, 6:28 AM
Azazul Islam
Azazul Islam - avatar