python version of javascript's arguments object - does it exist?

后端 未结 1 1367
遇见更好的自我
遇见更好的自我 2021-01-15 13:02

In JavaScript each function has a special arguments predefined objects which holds information about arguments passed to the function call, e.g.



        
1条回答
  •  鱼传尺愫
    2021-01-15 13:17

    It doesnt exist as is in python but you can call locals() as the first thing in the function and at that point it should only have the arguments

    >>> def f(a,b):
    ...    args = locals()
    ...    for arg, value in args.items():
    ...        print arg, value
    ...    return a*b
    ...
    

    0 讨论(0)
提交回复
热议问题