def f(**args):
print(args)
This gives TypeError exception. Though when I pass no args, like f(). It just prints nothing.
What could be the reason and how to pass args? I tried with f( [4,5]), but still same result
f only has a dictionary argument **args (more frequently written as **kwargs), which means that only keyword arguments are allowed (passing nothing at all is of course also allowed).
To enable positional arguments, add *args:
def f(*args,**kwargs)
or pass your parameter with any keyword:
f(foo=[4,5])
and kwargs["foo"] is [4,5] in f
** handles keyword arguments. So your function indeed doesn't take any positional arguments, only keyword arguments (or nothing).
Positional arguments are aggregated with *args, conventionally keyword arguments with **kwargs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With