Why make classes act like containers through magic methods? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why make classes act like containers through magic methods?

What advantages are there for making classes act like containers by using magic methods?

26th Dec 2021, 10:40 PM
Brad Nolan
Brad Nolan - avatar
2 Answers
0
Custom behavior for the spcific dataset.
26th Dec 2021, 10:56 PM
Slick
Slick - avatar
0
(2,3) + (2,4)....at first the computer does not know what the add operator does in this case.. so you can use magic methods to redefine what add means in the case of adding points
27th Dec 2021, 12:35 AM
Jamari McFarlane
Jamari McFarlane - avatar