[Python-ideas] Keyword-only arguments?
amber.yust at gmail.com
Wed Jun 17 20:58:00 CEST 2015
One thing that has been a source of bugs and frustration in the past is the
inability to designate a named keyword argument that cannot be passed as a
positional argument (short of **kwargs and then keying into the dict
directly). Has there been any previous discussion on the possibility of a
means to designate named arguments as explicitly non-positional?
Not a solid proposal, but to capture the essential difference of what I'm
thinking of, along the lines of...
def foo(bar, baz=None, qux: None):
where bar is a required positional argument, baz is an optional argument
that can have a value passed positionally or by name, and qux is an
optional argument that must always be passed by keyword.
Such a means would help avoid cases where a misremembered function
signature results in a subtle and likely unnoticed bug due to unintended
(It's possible that this has been discussed before - a cursory search of
python-ideas didn't bring up any direct discussion, but I may have missed
something. If you have a link to prior discussion, please by all means
point me at it!)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas