Skip to content

gh-125897: Use positional-only parameter indicators for range() #125945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1713,8 +1713,8 @@ are always available. They are listed here in alphabetical order.


.. _func-range:
.. class:: range(stop)
range(start, stop, step=1)
.. class:: range(stop, /)
range(start, stop, step=1, /)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think enumerating all three cases is slightly nicer. The step argument is for advanced use-cases. Thoguhts @terryjreedy?

Suggested change
range(start, stop, step=1, /)
range(start, stop, /)
range(start, stop, step, /)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally prefer fewer lines, partly from experience with IDLE call tips (which would be similar in other IDEs). Serhiy generally went with fewer in his PR, as he did here, except where really needed. Two are really needed here, since the true Python-implementaton signature (start_or_stop, stop_if_needed=None, step=1, /) is definitely too baroque for the doc.

Given your approval, I will merge this and backport (as Serhiy plans to backport his changes).

:noindex:

Rather than being a function, :class:`range` is actually an immutable
Expand Down
Loading