Get a list/tuple/dict of the arguments passed to a function?

前端 未结 8 1151
梦如初夏
梦如初夏 2020-12-01 13:17

Given the following function:

def foo(a, b, c):
    pass

How would one obtain a list/tuple/dict/etc of the arguments passed in, wit

8条回答
  •  春和景丽
    2020-12-01 14:07

    You can create a list out of them using:

    args = [a, b, c]
    

    You can easily create a tuple out of them using:

    args = (a, b, c)
    

提交回复
热议问题