Skip to content

Document '/' in signatures #65513

Closed
Closed

Description

@vedgar
mannequin
BPO 21314
Nosy @rhettinger, @terryjreedy, @ncoghlan, @larryhastings, @benjaminp, @jwilk, @encukou, @berkerpeksag, @zware, @pradyunsg, @MojoVampire, @vedgar, @csabella, @lysnikolaou, @pablogsal, @noahhaasis
PRs
  • bpo-21314: Add a FAQ entry about positional only parameters #10641
  • bpo-21314: Add a FAQ entry about positional only parameters #10641
  • bpo-21314: Add a FAQ entry about positional only parameters #10641
  • [3.7] bpo-21314: Add a FAQ entry about positional only parameters (GH-10641) #12266
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/larryhastings'
    closed_at = <Date 2022-04-04.20:43:41.240>
    created_at = <Date 2014-04-20.10:07:19.415>
    labels = ['easy', '3.7', '3.8', 'type-feature', 'expert-argument-clinic', 'docs']
    title = "Document '/' in signatures"
    updated_at = <Date 2022-04-04.20:43:41.236>
    user = 'https://github.com/vedgar'

    bugs.python.org fields:

    activity = <Date 2022-04-04.20:43:41.236>
    actor = 'petr.viktorin'
    assignee = 'larry'
    closed = True
    closed_date = <Date 2022-04-04.20:43:41.240>
    closer = 'petr.viktorin'
    components = ['Documentation', 'Argument Clinic']
    creation = <Date 2014-04-20.10:07:19.415>
    creator = 'veky'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 21314
    keywords = ['patch', 'patch', 'patch', 'easy']
    message_count = 22.0
    messages = ['216899', '216900', '216901', '219979', '219983', '219987', '223893', '323436', '324982', '325005', '328982', '330193', '330209', '337017', '337611', '337612', '337613', '337708', '337881', '343595', '344047', '416695']
    nosy_count = 18.0
    nosy_names = ['rhettinger', 'terry.reedy', 'ncoghlan', 'larry', 'benjamin.peterson', 'jwilk', 'petr.viktorin', 'docs@python', 'berker.peksag', 'zach.ware', 'pradyunsg', 'josh.r', 'veky', 'emily.zhao', 'cheryl.sabella', 'lys.nikolaou', 'pablogsal', 'noah.haasis']
    pr_nums = ['10641', '10641', '10641', '12266']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue21314'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    Activity

    1. vedgar commented on Apr 20, 2014

      vedgarmannequin
      MannequinAuthor

      Please look at the output of help(object.__ge__).

      1. What's that $ in front of self? lt and gt don't have it.

      2. What's that / as a third argument? Many wrapper functions have it (for example, see help(tuple.__len__).

      3. What's that -- as the first line of doc? Similar methods don't have it.

    2. MojoVampire commented on Apr 20, 2014

      MojoVampiremannequin
      Mannequin

      I don't know about the other bits, but that trailing '/' is how Argument Clinic (which makes full featured inspection available to built-in functions) notes that the parameters are positional only, and cannot be passed by keyword. See PEP-436.

    3. zware commented on Apr 20, 2014

      @zware
      Member
      1. This was due to a typo. The release of Python 3.4 saw the introduction of new introspection information on many C-implemented functions thanks to Argument Clinic (see PEP-436, I think it is). As part of that (still ongoing) transition, the default doctrings for type slots like __ge__ were given Argument Clinic-style signatures, and __ge__ had a typo.

      I fixed that typo on Friday (actually prompted by your previous issue about len's bad signature).

      1. That marker now shows that all proceeding arguments are positional-only. We should probably make sure that is well documented somewhere, possibly in the tutorial.

      2. This was also due to the typo I fixed.

    4. changed the title [-]Bizarre help[/-] [+]Document '/' in signatures[/+] on Apr 25, 2014
    5. emilyzhao commented on Jun 7, 2014

      emilyzhaomannequin
      Mannequin

      Can someone close this? I think it's fixed.

    6. benjaminp commented on Jun 7, 2014

      @benjaminp
      Contributor

      The original bug (junk in various doc strings) has been fixed, but I think the positional argument "/" syntax still needs docs. It's a little tricky because "/" is not actually valid syntax; it's just for documentation signatures.

    7. emilyzhao commented on Jun 7, 2014

      emilyzhaomannequin
      Mannequin

      where's the best place for that documentation to live?

    8. zware commented on Jul 24, 2014

      @zware
      Member

      Apologies for the delay in answering, Emily. And, unfortunately, I don't have a good answer. If you would like to write a patch, I would suggest just sticking the documentation wherever you think is best and make sure there is a link to it from the Symbols index page. Whoever commits your patch will either agree with your placement or have a better idea of where to put it, and will either move it themselves or work with you to move it.

      Here are a few possible places it could go, off the top of my head and without really looking:

      • in the pydoc docs
      • in the help() builtin docs
      • in or near the inspect.Signature docs
      • in the Clinic HOWTO
      • somewhere in the tutorial (though I'm not sure where would be good)
    9. 4 remaining items

    10. pradyunsg commented on Oct 31, 2018

      @pradyunsg
      Member

      We now have a PEP for this; just noting this here since I don't see a cross reference between them.

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

    11. lysnikolaou commented on Nov 21, 2018

      @lysnikolaou
      Member

      Noah, are you working on this?

    12. noahhaasis commented on Nov 21, 2018

      noahhaasismannequin
      Mannequin

      I don‘t have the time right now. Feel free to work on it!

    13. lysnikolaou commented on Mar 2, 2019

      @lysnikolaou
      Member

      Ping for review.

    14. ncoghlan commented on Mar 10, 2019

      @ncoghlan
      Contributor

      New changeset 1aeeaeb by Nick Coghlan (Lysandros Nikolaou) in branch 'master':
      bpo-21314: Add a FAQ entry about positional only parameters (GH-10641)
      1aeeaeb

    15. miss-islington commented on Mar 10, 2019

      @miss-islington
      Contributor

      New changeset 87f5255 by Miss Islington (bot) in branch '3.7':
      bpo-21314: Add a FAQ entry about positional only parameters (GH-10641)
      87f5255

    16. ncoghlan commented on Mar 10, 2019

      @ncoghlan
      Contributor

      I went ahead and merged Lysandros's new FAQ entry (Thank you Lysandros!), as having some level of documentation for this notation is markedly better than the previous "none at all", and the PR added cross-references from the builtins and inspect module docs in addition to adding the FAQ itself.

      However, I'm not closing the issue yet as:

      • the exact wording could likely stand to be tweaked a bit (in particular, I'm not sure it's a good idea to reference PEP-570 from the FAQ entry)

      • we may want to enhance pydoc itself to explain the notation inline (e.g. by appending a footer saying "Note: parameters to the left of / entries are positional only and cannot be passed by name" after the docstring being displayed when positional only parameters are found, and "Note: parameters to the right of * and *name entries are keyword only and can only be passed by name" when keyword only parameters are found)

      • we may want to file a follow-up issue proposing that pydoc go back to either not marking positional-only parameters at all, or marking them differently (e.g. with "Note: x, y, and z are positional only parameters that cannot be passed by name" after the individual callable docstrings)

    17. csabella commented on Mar 11, 2019

      @csabella
      Contributor

      There are a few other open issues about positional-only keywords (for example, bpo-10789 and bpo-8350). I wasn't sure what, if anything, could be done with those now that the '/' is available and documented.

    18. lysnikolaou commented on Mar 13, 2019

      @lysnikolaou
      Member

      I agree with Nick, that pydoc should somehow be updated to mark positional-only parameters as such. I believe that the third approach proposed by Nick is the most sensible one, as it makes the life of new developers easier by explicitly listing all the positional-only parameters. I could open a new issue and work on a PR, if you all agree that that is the way to go.

    19. pablogsal commented on May 27, 2019

      @pablogsal
      Member

      I think we can revisit this now that PEP-570 is accepted

    20. terryjreedy commented on May 31, 2019

      @terryjreedy
      Member

      Hooray! Now that PEP-570 is implemented in 3.8:

      >>> def f(a, /, *, b): return 3
      ...
      >>> f(0, b=2)
      3
      # other combinations raise

      and somewhat documented, ('/' in grammar of '8.6 Function definitions', though not explained, should its status become final and listing moved?

    21. encukou commented on Apr 4, 2022

      @encukou
      Member
      • PEP-570 (Python Positional-Only Parameters) is final
      • The language spec was updated to mention it
      • the FAQ entry was revised to not link to the PEP and be a self-contained explanation

      IMO the only thing left is to make searching for / yield the right results, but that is bpo-15871.
      Closing this issue.

    22. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions