I want to implement function overloading in Python. I know by default Python does not support overloading. That is what I am asking this question.
I have the following code:
def parse():
results = doSomething()
return results
x = namedtuple('x',"a b c")
def parse(query: str, data: list[x]):
results = doSomethingElse(query, data)
return results
The only solution I can think of is to check the arguments:
def parse(query: str, data: list[x]):
if query is None and data is None:
results = doSomething()
return results
else:
results = doSomethingElse(query, data)
return results
Is it possible to do function overloading in Python like in Java (i.e. with out the branching)?
Is there is a clear way using a decorator or some library?