[issue22785] range docstring is less useful than in python 2
New submission from Ned Batchelder: The Python 3.4 docstring for range is: {{{ | range(stop) -> range object | range(start, stop[, step]) -> range object | | Return a virtual sequence of numbers from start to stop by step. }}} In Python 2.7, it said: {{{ range(stop) -> list of integers range(start, stop[, step]) -> list of integers Return a list containing an arithmetic progression of integers. range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0. When step is given, it specifies the increment (or decrement). For example, range(4) returns [0, 1, 2, 3]. The end point is omitted! These are exactly the valid indices for a list of 4 elements. }}} Note that Python 3 seems to imply that the end-point is included, while Python 2 made clear that it was not. "Arithmetic progression" is a bit involved, but it would be good to mention that the end-point is omitted in the Python 3 docstring. ---------- assignee: docs@python components: Documentation messages: 230525 nosy: docs@python, nedbat priority: normal severity: normal status: open title: range docstring is less useful than in python 2 versions: Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22785> _______________________________________
Changes by Devin Jeanpierre <jeanpierreda@gmail.com>: ---------- nosy: +Devin Jeanpierre _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22785> _______________________________________
Changes by Antoine Pitrou <pitrou@free.fr>: ---------- stage: -> needs patch versions: +Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22785> _______________________________________
Raymond Hettinger added the comment:
Note that Python 3 seems to imply that the end-point is included
The Python 2 wording is better in this regard. Also, it would be nice clarify what is meant by "virtual sequence". I know what that means only because I already know what range() does. For someone who doesn't already know what it means, that phrase probably doesn't add any value. ---------- nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22785> _______________________________________
Changes by Ezio Melotti <ezio.melotti@gmail.com>: ---------- nosy: +benjamin.peterson type: -> enhancement _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22785> _______________________________________
Ned Batchelder added the comment: (By the time I got to the source, the word "virtual" had been removed...) Attached is a patch to make the help read: | range(stop) -> range object | range(start, stop[, step]) -> range object | | Return an object that produces a sequence of integers from start (inclusive) | to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1. | start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3. | These are exactly the valid indices for a list of 4 elements. | When step is given, it specifies the increment (or decrement). ---------- keywords: +patch Added file: http://bugs.python.org/file39163/22785.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22785> _______________________________________
Roundup Robot added the comment: New changeset aa6b73823685 by Benjamin Peterson in branch '3.4': improved range docstring (closes #22785) https://hg.python.org/cpython/rev/aa6b73823685 New changeset c031fa8e6884 by Benjamin Peterson in branch 'default': merge 3.4 (#22785) https://hg.python.org/cpython/rev/c031fa8e6884 ---------- nosy: +python-dev resolution: -> fixed stage: needs patch -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22785> _______________________________________
participants (6)
-
Antoine Pitrou
-
Devin Jeanpierre
-
Ezio Melotti
-
Ned Batchelder
-
Raymond Hettinger
-
Roundup Robot