0

Magic methods

I do not understand this topic how relavant is u the python programming?

12th Oct 2018, 2:53 AM
Ruben F. Villanueva Viana
Ruben F. Villanueva Viana - avatar
2 Antworten
+ 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.
12th Oct 2018, 3:04 AM
Zeke Williams
Zeke Williams - avatar
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
6th Aug 2021, 2:02 PM
сергей
сергей - avatar