What exactly the third argument of decorated function with api.route does?
tomoyks opened this issue · 2 comments
tomoyks commented
Here is an example code of responder.
import responder
api = responder.API()
@api.route("/{greeting}")
async def greet_world(req, resp, *, greeting):
resp.text = f"{greeting}, world!"
if __name__ == '__main__':
api.run()
I wonder what is the role of third argument asterisk.
I think here is the line which call route function but I couldn't find any part which give value corresponds third augment asterisk.
Please tell me the role of third argument of decorated function with api.route does.
Thank you.
taoufik07 commented
Docs: https://www.python.org/dev/peps/pep-3102/
Using *
tells python to only accept keyword-only arguments after it (*
)
>>> def func(a, b, *, c):
print(a, b, c)
>>> func(1, 2, 3) # Will raise an error
>>> func(1, 2, c=3) # 1, 2, 3
tomoyks commented
Now it becomes clear, thank you for answering!