Is function overloading supported by Python? Give reasons.
Advertisements
Advertisements
Question
Is function overloading supported by Python? Give reasons.
Give Reasons
Advertisements
Solution
No. Python does not support traditional function overloading based on different parameter lists.
- A function name can refer to only one function definition at a time.
- If the same function name is defined again, the latest definition overwrites the earlier one.
- Similar behaviour can be achieved in Python using default arguments, variable-length arguments (
*args), or type checking.
shaalaa.com
Is there an error in this question or solution?
