GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — documentation for function arguments · Issue #91485 · python/cpython

documentation for function arguments #91485

New issue
Copy link
New issue
Copy link
Closed
Closed
documentation for function arguments#91485
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@vainaixr
vainaixr
opened on Apr 12, 2022
Issue body actions

it is confusing what these mean, is there a page which explains the difference between these, or if not, then could there be a page which explains the difference between these, (and more variations)

max(iterable, *[, key, default])
max(arg1, arg2, *args[, key])
iter(object[, sentinal])
input([prompt])
itertools.accumulate(iterable[, func, *, initial=None])

Linked PRs

  • gh-91485: Avoid unnecessary use of non-Python syntax in io docs #101177
  • [3.11] gh-91485: Avoid unnecessary use of non-Python syntax in io docs (GH-101177) #101199
  • [3.10] gh-91485: Avoid unnecessary use of non-Python syntax in io docs (GH-101177) #101200

Activity

  1. eugenetriguba commented on Apr 13, 2022

    @eugenetriguba
    eugenetriguba
    on Apr 13, 2022
    Contributor
    More actions

    https://docs.python.org/3/library/functions.html
    https://docs.python.org/3/library/itertools.html#itertools.accumulate

    I'm assuming these are what you're referring to?

  2. vainaixr commented on Apr 13, 2022

    @vainaixr
    vainaixr
    on Apr 13, 2022
    ContributorAuthor
    More actions

    i meant the meaning of the arguments, like the *[, i do not know if there are more variations to that.

  3. JulienPalard commented on Apr 13, 2022

    @JulienPalard
    JulienPalard
    on Apr 13, 2022
    Member
    More actions

    Maybe the function docs could be made easier to read by sticking to Python syntax?

    As / and * are valid in Python syntax, I can easily imagine a newcomer thinking that *[ is valid too (it may be the case here).

    By sticking to valid Python syntax (reminds me of the repr philosophy) developers would read them more easily, maybe, but it means lots of None, like:

    max(iterable, *[, key, default])  →  max(iterable, *, key=None, default=None)
    max(arg1, arg2, *args[, key])  →  max(arg1, arg2, *args, key=None)
    iter(object[, sentinal])  →  iter(object, sentinel=None, /)
    input([prompt])  →  input(prompt='', /)
    itertools.accumulate(iterable[, func, *, initial=None])  →  itertools.accumulate(iterable, func=None, *, initial=None)
    

    It would mean checking if that's actually true that they expect None as the default value, they may expect a sentinel value. Typically here for input the default value is the empty string, not None.

    In case like range where there's no clean way to describe the function using Python, or for functions expecting a sentinel to tell if they received the value or not, we could just list alternative calls, as we actually do for range, like:

    class range(stop)
    class range(start, stop, step=1)
    

    does my rewritings helps you understand, @vainaijr?

    Reacted by Jelle Zijlstra
  4. vainaixr commented on Apr 13, 2022

    @vainaixr
    vainaixr
    on Apr 13, 2022
    ContributorAuthor
    More actions

    yes, thanks for the explanation

  5. AlexWaygood
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 21, 2022
  6. miss-islington
    added a commit that references this issue on Oct 15, 2022

    pythongh-91485: Doc: Using Python syntax to document builtin Python f…

    33f6dfe
  7. JulienPalard
    added a commit that references this issue on Oct 15, 2022

    gh-91485: Doc: Using Python syntax to document builtin Python functio…

    3c4cbd1
  8. miss-islington
    added a commit that references this issue on Oct 15, 2022

    gh-91485: Doc: Using Python syntax to document builtin Python functio…

    42d536c
  9. JulienPalard
    added a commit that references this issue on Oct 17, 2022

    Revert "gh-91485: Doc: Using Python syntax to document builtin Python…

    cc68058
  10. pablogsal
    added a commit that references this issue on Oct 22, 2022

    gh-91485: Doc: Using Python syntax to document builtin Python functio…

    3737a0e
  11. hauntsaninja
    added a commit that references this issue on Jan 20, 2023

    pythongh-91485: Avoid unnecessary use of non-Python syntax in io docs

    fc40849
  12. hauntsaninja commented on Jan 20, 2023

    @hauntsaninja
    hauntsaninja
    on Jan 20, 2023
    Contributor
    More actions

    I agree that we should try and stick to using Python syntax where possible.

    Grepping Doc/ for *[ I found a couple uses, however only the one in io has documentable default values #101177 . So after that is merged, I will close this issue since there's a larger discussion to be had about how to document those kinds of functions (e.g. maybe use ... as the default value?). E.g. see python/devguide#1020

  13. ambv
    added a commit that references this issue on Jan 20, 2023

    gh-91485: Avoid unnecessary use of non-Python syntax in io docs (#101177

    783d1bc
  14. miss-islington
    added 4 commits that reference this issue on Jan 20, 2023

    pythongh-91485: Avoid unnecessary use of non-Python syntax in io docs (…

    0188803

    pythongh-91485: Avoid unnecessary use of non-Python syntax in io docs (…

    bb18bc6

    gh-91485: Avoid unnecessary use of non-Python syntax in io docs (GH-1…

    0dc35e4

    gh-91485: Avoid unnecessary use of non-Python syntax in io docs (GH-1…

    23bb5f3
  15. hauntsaninja
    closed this as completedon Jan 20, 2023
  16. arhadthedev commented on Jan 21, 2023

    @arhadthedev
    arhadthedev
    on Jan 21, 2023
    Member
    More actions

    max(iterable, *[, key, default]) → max(iterable, *, key=None, default=None)

    Previously I've thought that *[...] means "an optional group that can be repeated". For "optional named-only arguments" I would expect *, [...].

    In other words, I would parse max(iterable, *[, key, default]) as:

    • max(iterable)
    • max(iterable, key, default)
    • max(iterable, key1, default1, key2, default2)
    • ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.