Is it possible to set a default value for a variable argument list in Python 3?
Something like:
def do_it(*args=(2, 5, 21)):pass
I wonder that a variable argument list is of type tuple
but no tuple is accepted here.
Is it possible to set a default value for a variable argument list in Python 3?
Something like:
def do_it(*args=(2, 5, 21)):pass
I wonder that a variable argument list is of type tuple
but no tuple is accepted here.
If not syntactically, then depending on what behavior you want:
def do_it(*args):if not args: args = (2, 5, 21)
or
def do_it(a=2, b=5, c=21, *args):args = (a,b,c)+args
should do it.