Operator Overloading
suggest changeEverything in Python is an object. Each object has special methods which it uses to interact with other objects. Generally, these methods follow the __action__ naming convention. Collectively, this is the Python data model.
A class can implement these methods to support operators. The interpreter looks them up on the class, not on the instance. Numeric special methods such as __add__ and __mul__ are documented under emulating numeric types.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents