+ 5
Can i do function overloading in python like java?
7 Antworten
+ 11
I don't think so. Only the last definition of the function would be used. But we could define one function that takes, for example, 1, 2, or 3 arguments--like the built-in range().
+ 4
Okay, thanks Sarvesh! That's what I alluded to in my first comment in this post.
But despite having similar effect, it's not exactly the same as function overloading in Java--which, as far as I know, refers to having more than one function with the same name and typically similar job but different number/type of arguments. Here you have just one function.
+ 4
I have studied only this way of function overloading in python
+ 4
Nice, but that's not function overloading, even though it gives you the same result.
+ 2
Yes ,can be done
+ 1
Sarvesh ✓ , would you mind giving an example? Thanks.