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()

27th Jun 2017, 4:39 AM
Abhishek Hugar
Abhishek Hugar - avatar
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.
27th Jun 2017, 9:15 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar