Possible Duplicate:
What does *args and **kwargs mean?
From reading this example and from my slim knowledge of Python it must be a shortcut for converting an array to a dictionary or something?
class hello:
def GET(self, name):
return render.hello(name=name)
# Another way:
#return render.hello(**locals())
In python f(**d)
passes the values in the dictionary d
as keyword parameters to the function f
. Similarly f(*a)
passes the values from the array a
as positional parameters.
As an example:
def f(count, msg):
for i in range(count):
print msg
Calling this function with **d
or *a
:
>>> d = {'count': 2, 'msg': "abc"}
>>> f(**d)
abc
abc
>>> a = [1, "xyz"]
>>> f(*a)
xyz
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