[Python-ideas] Keyword-only arguments?

Joseph Jevnik joejev at gmail.com
Wed Jun 17 21:32:36 CEST 2015


I use it for all of my python3 only code for all of the reasons that you
mentioned. One of the main reasons that it is not used is that many people
try to make their code work with 2 and 3.

On Wed, Jun 17, 2015 at 3:11 PM, Amber Yust <amber.yust at gmail.com> wrote:

> Interesting. I don't think I've ever seen it used, even having looked at
> Python 3 code. For those who have worked with more Python 3 code than I
> have, do you ever see it used?
>
> On Wed, Jun 17, 2015 at 12:02 PM Chris Kaynor <ckaynor at zindagigames.com>
> wrote:
>
>> On Wed, Jun 17, 2015 at 11:58 AM, Amber Yust <amber.yust at gmail.com>
>> wrote:
>>
>>> 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
>>> parameter/argument mismatch.
>>>
>>> (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!)
>>>
>>
>> This feature was added to Python 3 about 9 years ago, see
>> https://www.python.org/dev/peps/pep-3102/. A quick search for "python
>> keyword only arguments" on Google found it.
>>
>> Guido's time machine strikes again!
>>
>> Chris
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150617/5136cb96/attachment.html>


More information about the Python-ideas mailing list