Like other languages (for example method overloading in C++) do, python does not supports method overloading. We may overload the methods but can only use the latest defined method.
In the above code we have defined two product method, but we can only use the second product method, as python does not supports method overloading. We may define many method of same name and different argument but we can only use the latest defined method. Calling the other method will produce an error. Like here calling will produce an error as the latest defined product method takes three arguments.
However we may use other implementation in python to make the same function work differently i.e. as per the arguments.
11 Hi Geeks
- Operator Overloading in Python
- Function overloading with singledispatch-functools
- class method vs static method in Python
- Python | os.dup() method
- Python | next() method
- Python | set() method
- Python | PyTorch tan() method
- Python | PyTorch cos() method
- Python PIL | ImageChops.add() method
- Python PIL | getbands() method
- Python | sympy.tan() method
- Python | sympy.sin() method
- Python | sympy.cos() method
- Python PIL | blend() method
- Python | os.utime() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.