0
Magic methods
I do not understand this topic how relavant is u the python programming?
2 Answers
+ 2
Python is relevant in many circumstances. Its large number of modules makes Python so versatile. For instance, we use it at the place I work for use with system commands and scripts in the Bash shell.
I don't know much about magic methods however, but a quick Google search should serve you well.
0
Magic methods are metods that are start with __ and ends with __, for example, you have class integer, and if you do integer + integer, integer's __add__ method will be called with two arguments: the integer class of __add__ (usually self), and the another class (i usually name it other). So you need to use magic method __add__ like:
def __add__(self, other):
return self.i + other.i