AI engineering glossary · Python advanced
What is dunder method?
Dunder method (also called Magic method, Special method): A special method whose name starts and ends with double underscores, such as __len__ or __add__. Python calls these automatically to support built-in syntax and functions on your own classes. Also called a magic or special method.
Dunder method: an example
Defining __len__ in your class lets len(obj) work; defining __add__ lets you write obj1 + obj2.
Related terms
More Python advanced terms
Where you learn it
Dunder method is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.