Python Tutorial
Python - Introduction Python - Syntax Python - Variable Python - Number Python - Casting Python - String Python - Operators Python - Conditions Python - Loops Python - List Python - Tuple Python - Set Python - Dictionary Python - Function Python - Module Python - Date & Time Python - Input Output Python - Error & Exception Python - File Handling
Python OOP
OOP - Introduction OOP - Class Members OOP - Constructor Destructor OOP - Data Hiding OOP - Inheritance OOP - Overriding OOP - Overloading

Python Overloading Operators

You can change the meaning of an operator in Python depending upon the operands used. This practice is known as operator overloading.

Python operators work for built-in classes. But same operator behaves differently with different types.

For example, the + operator will, perform arithmetic addition on two numbers, merge two lists and concatenate two strings.

This feature in Python, that allows same operator to have different meaning according to the context is called operator overloading.


Special Functions in Python

Class functions that begins with double underscore __ are called special functions in Python.

This is because, well, they are not ordinary. Example: __init__().

Learn more about special functions here


Overloading the + Operator in Python

To overload the + operator, we will need to implement __add__() function in a class.

With great power comes great responsibility. We can do whatever we like, inside this function.