Are the magic methods poorly explained on the app??

Managed completing the OOP section but we all know that without understanding the magic methods, it's all a lie lol

7/21/2019 8:27:45 AM

John Doe's Johnny

4 Answers

New Answer


I think I get it. will go over it. thanks


Mostly about how to use __getitem__ ,__setitem__ and __iter__


You'll need them if you want to create your own container types. Like if you want to do stuff with a bunch of values, but none of the built-in containers - like list, dict, set - does exactly what you want. Then you can design another container type. And you want to use it conveniently, using operators, +, * ir something, or indexing it with [ ]... In most cases magic methods allow you this: define what happens if you use a specific syntax.


The tutorials are very brief and give only an overview which you're going to fill with more detail as you continue to learn. What exactly didn't you understand?