I know that *args
and **kwargs
are ways to feed more arguments into a function in Python.
I am wondering where these terms stem from. Why have all the asterisks in the beginning? What does the kw in kwargs stand for?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.
Sign up to join this communityI know that *args
and **kwargs
are ways to feed more arguments into a function in Python.
I am wondering where these terms stem from. Why have all the asterisks in the beginning? What does the kw in kwargs stand for?
The "kw" stands for Key Word because the dictionary that you pass in is expanded to a sequence of key-word pair arguments. As to "Why have all the asterisks in the beginning?" I ask you, why not have them?
My hypothesis as to why the * characters were chosen is that they frequently have a wildcard meaning (e.g., in regular expressions or globing). This is just guess-work though and I have nothing to document that.
kwargs
and only three timesargs
, but in places where it doesn't answers the OP's question