python / python/cpython

Built-in function `range` params discrepancy across versions

オープン
#125,897 コメント 10 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

3.12 3.13 3.14 docs
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

I'm sorry if this has already been reported. I'm sure it's very low on any list of priorities but it should be an easy one.

I noticed that when doing a Google search for "python built in functions" I am presented with two official results:

  1. functions https://docs.python.org/3/library/functions.html
  2. stdtypes https://docs.python.org/3/library/stdtypes.html

On the functions page, clicking on range takes you to https://docs.python.org/3/library/functions.html#func-range . It looks like, as of 3.11, range accepts step as a kwarg. This is inconsistent with the stdtypes page which shows step as an optional, positional arg through 3.13.

functions:

stdtypes:

source:

I didn't see any mention of this change in What’s New In Python 3.11 and it surprised me that a built-in would be changed in such a way.

I pulled a 3.11 docker image and it would seem step is not a kwarg.

docker run -it --rm python:3.11
Python 3.11.10 (main, Oct 19 2024, 04:02:01) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> range(1, 1, step=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: range() takes no keyword arguments

tl;dr - The functions page incorrectly states that the range function accepts step as a kwarg.

Linked PRs
  • gh-125945
  • gh-137652
  • gh-137653

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

バージョン3.10から3.13について、functions および stdtypes ドキュメントページの range の記述を比較し、リンクされている rangeobject.c ソースを使って呼び出し動作を検証してください。リンクされている PR gh-125945、gh-137652、gh-137653 を確認してください。ドキュメントに step がキーワード引数として受け入れられると記載されなくなれば、作業は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
documentation
issue の種類
ドキュメント
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。