Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. OOPs concept in Python
  5. Overloading in Python

Overloading in Python

Overloading refers to the ability of an operator to behave in different ways depending on the parameters that are passed to the function, or the operands that the operator acts on. 

Operator overloading using magic methods:-

int1+int2
str1+str2
tuple1+tuple2

Changing the functionality of the operator depending on what operands are given is called operator overloading.

e.g.,

print(1 + 2) 
print("Python"+"point") 
print(3 * 4) 
print("Python"*4) 
Output-
3
pythonpoint
12
pythonpythonpythonpython

This is all about overloading in python.

Was this article helpful to you? Yes No

How can we help?