function - Python 3.X using multiple *args for different stuff -
i know *args used when dunno how many args being used inside function call. however, do when want 1 group of *args x , 1 group of *args y?
you can not pass 2 *args
within single function. need pass args1
, args2
plain list
, may pass these lists args functions doing x
, y
. example:
def do_x(*args): # def do_y(*args): # more thing def my_function(list1, list2): do_x(*list1) # pass list `*args` here do_y(*list2)
and call my_function
like:
args_1 = ['x1', 'x2'] # group of arguments doing `x` args_2 = ['y1', 'y2'] # group of arguments doing `y` # call function my_function(args_1, args_2)
Comments
Post a Comment