hehe, no not at all. I just tried to show my thought process when analyzing the problem. The one time I have seen magic methods called directly is when using inheritance: super().__init__(x, y, z); x,y,z being som parameters to the constructor. Also list.__getitem__(my_list, 1) is exactly the same as my_list.__getitem__(1), this is just passing the parameter self manually to the function. If you want to, you can do this swap with any instance method on any class.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
But, is it normal to call a magic method?
hehe, no not at all. I just tried to show my thought process when analyzing the problem. The one time I have seen magic methods called directly is when using inheritance:
super().__init__(x, y, z)
; x,y,z being som parameters to the constructor. Alsolist.__getitem__(my_list, 1)
is exactly the same asmy_list.__getitem__(1)
, this is just passing the parameter self manually to the function. If you want to, you can do this swap with any instance method on any class.