Skip to content Skip to sidebar Skip to footer

Python Version Of Javascript's Arguments Object - Does It Exist?

In JavaScript each function has a special arguments predefined objects which holds information about arguments passed to the function call, e.g. function test() { var args = Arra

Solution 1:

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
...

Post a Comment for "Python Version Of Javascript's Arguments Object - Does It Exist?"