What is the Python convention **kwargs vs **kwds vs **kw?

Question:

Is there a python naming convention for key word arguments?

Asked By: Kyle Finley

||

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.

Answered By: Senthil Kumaran

The most popular convention is **kwargs, as seen in documentation and PEPs.

Answered By: Jasmijn

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.

Answered By: Noufal Ibrahim
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.