What is the Python convention **kwargs vs **kwds vs **kw?
Question:
Is there a python naming convention for key word arguments?
Answers:
Nope, but normally it is named as **kwargs
, but you can name it anything you want. Only thing is it should come at the last following any position args and named args.
The most popular convention is **kwargs
, as seen in documentation and PEPs.
The key is consistency. In your personal code and in the project on which you’re working. If I’m reading your code and see you using **kwarguments
in all functions, I can calibrate myself to read it fine. If you use **k
in one place and **kargs
in another, that’s a different story.
As for conventions in Python code generally, my experience is the same as Senthil’s – **kwargs
.
Is there a python naming convention for key word arguments?
Nope, but normally it is named as **kwargs
, but you can name it anything you want. Only thing is it should come at the last following any position args and named args.
The most popular convention is **kwargs
, as seen in documentation and PEPs.
The key is consistency. In your personal code and in the project on which you’re working. If I’m reading your code and see you using **kwarguments
in all functions, I can calibrate myself to read it fine. If you use **k
in one place and **kargs
in another, that’s a different story.
As for conventions in Python code generally, my experience is the same as Senthil’s – **kwargs
.