Answer the question
In order to leave comments, you need to log in
How to check function/method arguments?
Hello everyone, there is a certain method or function that accepts a limited number of incoming arguments:
def foo(a: str = None, b: str = None, c: int = None):
...
Answer the question
In order to leave comments, you need to log in
If the argument is None, does that mean some default value should be used? If yes, then you can take out if on this argument separately, and then behave as if the argument was given.
If not, then you should ask yourself - isn't this function taking on too much? Shouldn't it be divided into several?
Rewrite the function so that it would work normally with None. Just as for me, if your function may not take arguments at all, then it is more logical to pack everything into:
def foo(*args, **kwargs):
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question