Skip to content

Module 10 Overview

Module 10: Magic Methods (or “Dunder” methods, short for Double UNDERscore) allows you to define how your objects behave with built-in Python operators and functions.

Have you ever wondered why you can use + to add numbers and concatenate strings? Or why len() works on lists, tuples, and strings? This is achieved through magic methods.

By the end of this module, you will be able to:

  • Customize how your objects are printed using __str__ and __repr__.
  • Implement Operator Overloading to allow using +, -, * with your objects.
  • Make your objects behave like lists or dictionaries using Container Emulation.
  • Understand the Python Data Model and how the interpreter interacts with your classes.