Python kwargs Function

Python **kwargs usually used to let functions take arbitrary number of keyword arguments.

>>> def f(**kwargs):
... for key in kwargs:
... print(key,kwargs[key])
...
>>> f(a=3,b=4,c=12)
a 3
b 4
c 12
>>> f(name="Jack Martin")
name Jack Martin


















endmemo.com © 2024  | Terms of Use | Privacy | Home