DEV Community

loading...

Discussion on: TIL: Python Recursion Limit When Accessing Elements in Recursive List

Collapse
fronkan profile image
Fredrik Bengtsson Author

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.