3 odpowiedzi
+ 11
you have to draw a pentagram with beetle juice and chant import this 999 times and then summon the python spirit who will tell you to meet monty in britian. monty will bring you to Hogwarts and there you can learn the magical method
+ 6
On top of what Ahri suggested, they *also* might be used in class definition. You for example always define the __init__ magic method. Apart from defining the class's features, you may for example tell it to increment a counter each time an object is instantiated. So you can keep track of how many of such objects were created already.
But really vast applications of this - you usually define __str__ or __repr__ which define how the print(object_name) should behave. You can overload standard operators, customize attribute access and many more.
0
If you make a class for vectors, you likely want to add them. So use magic method to get + on vectors.