A class can implement certain operations that are invoked by special syntax (such as arithmetic operations or subscripting and slicing) by defining methods with special names. This is Python’s approach to operator overloading, allowing classes to define their own behavior with respect to language operators
Python Docs :- docs.python.org/3/reference/datamodel.html#basic-customization
Негізгі бет Special method names or Dunder __str__ , __repr__ , __add__ - Python OOPs 08
Пікірлер: 15