classification
Title: range is not a built-in function
Type: behavior Stage:
Components: Documentation Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: bgailer, docs@python, terry.reedy
Priority: normal Keywords:

Created on 2019-06-27 15:39 by bgailer, last changed 2019-06-29 15:59 by terry.reedy.

Messages (4)
msg346745 - (view) Author: bob gailer (bgailer) Date: 2019-06-27 15:39
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.
msg346753 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-06-27 16:19
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.
msg346784 - (view) Author: bob gailer (bgailer) Date: 2019-06-27 23:00
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.
msg346887 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-06-29 15:59
Then it appears the indexing could also be improved.
History
Date User Action Args
2019-06-29 15:59:20terry.reedysetmessages: + msg346887
2019-06-27 23:00:47bgailersetmessages: + msg346784
2019-06-27 16:19:19terry.reedysetnosy: + terry.reedy

messages: + msg346753
versions: + Python 3.9, - Python 3.5, Python 3.6
2019-06-27 15:39:32bgailercreate