Skip to content

[doc] range is not a built-in function #81611

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

Closed
bgailer mannequin opened this issue Jun 27, 2019 · 7 comments · Fixed by #98353
Closed

[doc] range is not a built-in function #81611

bgailer mannequin opened this issue Jun 27, 2019 · 7 comments · Fixed by #98353
Labels
3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy type-bug An unexpected behavior, bug, or error

Comments

@bgailer
Copy link
Mannequin

bgailer mannequin commented Jun 27, 2019

BPO 37430
Nosy @terryjreedy, @slateny

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 = None
closed_at = None
created_at = <Date 2019-06-27.15:39:32.877>
labels = ['easy', 'type-bug', '3.9', '3.10', '3.11', 'docs']
title = '[doc] range is not a built-in function'
updated_at = <Date 2022-03-28.09:10:10.773>
user = 'https://bugs.python.org/bgailer'

bugs.python.org fields:

activity = <Date 2022-03-28.09:10:10.773>
actor = 'slateny'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2019-06-27.15:39:32.877>
creator = 'bgailer'
dependencies = []
files = []
hgrepos = []
issue_num = 37430
keywords = ['easy']
message_count = 5.0
messages = ['346745', '346753', '346784', '346887', '416153']
nosy_count = 4.0
nosy_names = ['terry.reedy', 'bgailer', 'docs@python', 'slateny']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue37430'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

Linked PRs

@bgailer
Copy link
Mannequin Author

bgailer mannequin commented Jun 27, 2019

In section 8.3 The for statement there is a reference to range as a built-in function. That was true in python 2. Now range is a built-in type.

@bgailer bgailer mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life labels Jun 27, 2019
@bgailer bgailer mannequin assigned docspython Jun 27, 2019
@bgailer bgailer mannequin added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error labels Jun 27, 2019
@terryjreedy
Copy link
Member

I presume you are referring to 8.3 of the language reference
https://docs.python.org/3/reference/compound_stmts.html#the-for-statement
which has "the built-in function range()". Types/classes *are* functions, which is why dist, list, range, etc are listed in "Built-in Functions" in the library reference. But I agree that the more specific term should be used.

To me, the more severe problem is with the complete sentence.

"Hint: the built-in function range() returns an iterator of integers suitable to emulate the effect of Pascal’s for i := a to b do; e.g., list(range(3)) returns the list [0, 1, 2]."

The now obsolete definition of Python in terms of the now obscure Pascal should be deleted here and anywhere else such remains. I think the whole sentence should just be deleted. The whole paragraph and example could otherwise be improved.

@terryjreedy terryjreedy added the 3.9 only security fixes label Jun 27, 2019
@bgailer
Copy link
Mannequin Author

bgailer mannequin commented Jun 27, 2019

Thanks for explaining. Indeed range appears in __builtins__. It is a surprise to type range and get <class 'range'> in response. sum otoh gives <built-in function sum>. The distinction between function, type and class seems muddy.

When I enter "range" in the index box in the windows documentation display I am offered:

(1)built-in function, which takes me to the paragraph that started this issue. It does NOT take me to the built-in functions topic, whereas sum does.

(2) object, and range (built-in class)which take me to the built-in types topic. This seems to add to the confusion.

@terryjreedy
Copy link
Member

Then it appears the indexing could also be improved.

@iritkatriel iritkatriel added easy 3.10 only security fixes 3.11 only security fixes and removed 3.7 (EOL) end of life 3.8 (EOL) end of life labels Mar 24, 2022
@iritkatriel iritkatriel changed the title range is not a built-in function [doc] range is not a built-in function Mar 24, 2022
@slateny
Copy link
Contributor

slateny commented Mar 28, 2022

Terry, how do you think the example/paragraph should be improved? I notice that the previous paragraphs talk about continue/break/else, so were you looking for some new example with all those? And I think the indexing's been fixed by now, but a clickable link to the range() documentation (https://docs.python.org/3/library/stdtypes.html#range) might still be a good idea just for convenience.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
kumaraditya303 added a commit that referenced this issue Jan 3, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 3, 2023
pythonGH-98353)

(cherry picked from commit 8b1f125)

Co-authored-by: 4l4k4z4m <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 3, 2023
pythonGH-98353)

(cherry picked from commit 8b1f125)

Co-authored-by: 4l4k4z4m <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue Jan 4, 2023
…ce (GH-98353) (#100704)

gh-81611: Improve `range` paragraph in 8.3 of language reference (GH-98353)
(cherry picked from commit 8b1f125)

Co-authored-by: 4l4k4z4m <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue Jan 4, 2023
…ce (GH-98353) (#100705)

gh-81611: Improve `range` paragraph in 8.3 of language reference (GH-98353)
(cherry picked from commit 8b1f125)

Co-authored-by: 4l4k4z4m <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
@terryjreedy terryjreedy removed the 3.9 only security fixes label Jan 4, 2023
@terryjreedy
Copy link
Member

Kumar, in my opinion, issues should not be closed until the backports are merged.

@kumaraditya303
Copy link
Contributor

Kumar, in my opinion, issues should not be closed until the backports are merged.

Yeah, I usually approve backports and close the issue but because of the CLA issues PRs were delayed this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants