0
Is function overloading not possible in Python?
def my_func(): print("spam") print("spam") print("spam") def my_add(a,b): print(a+b) def my_func(a,b): print(a*b) my_add(10,20) my_func(2,5) my_func()
1 Resposta
+ 5
It is *possible* and... meaningless at the same time :) Since Python is a dynamically-typed language, it can't be done like in the strict/strong-typed ones.
There are workarounds like checking the type inside a function or using @decorators, but in most of the cases - it's not the way it's done.