Python Forum
Extra Argument In Help Response - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Extra Argument In Help Response (/thread-19235.html)



Extra Argument In Help Response - z3driver - Jun-19-2019

I'm using IDLE with Python 3.7.3 in Windows. When requesting help for some built-in functions (e.g. get and setdefault) I'm getting back documentation that appears to indicate there is 1 more argument than the functions actually support. Here are some responses from IDLE. I tried from a Windows command prompt and see the same thing.

>>> help({}.get)
Help on built-in function get:

get(key, default=None, /) method of builtins.dict instance
    Return the value for key if key is in the dictionary, else default.

>>> help({}.setdefault)
Help on built-in function setdefault:

setdefault(key, default=None, /) method of builtins.dict instance
    Insert key with a value of default if key is not in the dictionary.
    
    Return the value for key if key is in the dictionary, else default.
Why is there what appears to be an extra argument (", /") at the end of the list? What's the purpose of the ", /" at the end? Is it a bug in the documentation?

Thanks for any explanations you can provide.


RE: Extra Argument In Help Response - stranac - Jun-19-2019

The / indicates that the args before it are positional-only, they can not be passed as keyword arguments.


RE: Extra Argument In Help Response - nilamo - Jun-19-2019

For more reading:
https://www.python.org/dev/peps/pep-0570


RE: Extra Argument In Help Response - z3driver - Jun-19-2019

Thanks for the answer. Based on your answer, I was able to locate PEP 570 -- Python Positional-Only Parameters. This PEP provides some additional history and other information on the topic.