Teaching the "range" function in Python 3

Chris Angelico rosuav at gmail.com
Fri Jun 30 23:35:51 EDT 2017


On Sat, Jul 1, 2017 at 1:25 PM, MRAB <python at mrabarnett.plus.com> wrote:
> On 2017-07-01 03:12, Stefan Ram wrote:
>>
>> Terry Reedy <tjreedy at udel.edu> writes:
>>>
>>> range is a class, not a function in the strict sense.
>>
>>
>>        »the built-in function range() returns an iterator of integers«
>>
>>      The Python Language Reference, Release 3.6.0, 8.3 The for statement
>>
> Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit
> (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> range
> <class 'range'>
>
> I think it's a holdover from Python 2:
>
> Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> range
> <built-in function range>
>>>> xrange
> <type 'xrange'>

I think you're right. It's no longer correct. Let's fix it.

https://github.com/python/cpython/pull/2523

ChrisA



More information about the Python-list mailing list