Say that I have a function with this signature foo(*args,a:int=0, b:int=1).
How to check if no *args is passed?
I am trying
def foo(*args,a:int=0, b:int=1):
if args is None:
print("No args passed")
If I call it with foo(), but I don’t get anything printed on screen.
>Solution :
In conclusion:
Use not args or args == ()
def foo(*args, a:int=0, b:int=1):
if not args:
print("No args passed")
foo()
def foo(*args, a:int=0, b:int=1):
if args == ():
print("No args passed")
foo()