Python Forum
Extra Argument In Help Response
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extra Argument In Help Response
#1
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.
Reply
#2
The / indicates that the args before it are positional-only, they can not be passed as keyword arguments.
Reply
#3
For more reading:
https://www.python.org/dev/peps/pep-0570
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SyntaxError: positional argument follows keyword argument syd_jat 3 5,729 Mar-03-2020, 08:34 AM
Last Post: buran
  An Extra 'None' leoahum 5 3,821 Oct-18-2018, 08:20 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020