[Python]: Check that no *args. is passed
Question:
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.
Answers:
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()
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.
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()