What are dunder (magic) methods?
Model answer
Special methods with double underscores that Python calls for built-in behaviour: __len__ for len(), __eq__ for ==, __add__ for +, __getitem__ for indexing, __iter__ for loops, and __enter__/__exit__ for with. Implementing them makes your classes feel natural.
Learn this topic
Classes and Objects in Python: A Gentle Introduction in the course Python for Beginners: Learn to Code with Real Projects.
Sign in to add your own answer.