Strange range

Chris Angelico rosuav at gmail.com
Sun Apr 3 03:10:42 EDT 2016


On Sun, Apr 3, 2016 at 4:58 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> That a use exists in the standard library, or that one does not,
>> doesn't really tell you anything meaningful about Python itself or
>> good practices with the language. The standard library is under
>> uniquely conservative constraints that enshrine compatibility and
>> reliability from one point release to another over any kind of
>> innovation.
>
> What you seem to be saying is that range() used to be an iterator but
> has since ascended to the status of an iterable.

No, range() has never returned an iterator. In Python 2, it returned a
list, which is iterable. In Python 3, it returns a range object, which
is iterable. And in Python 2, xrange returns an xrange object, which
is also iterable (but less functional than the Py3 range object). None
of these is an iterator.

ChrisA



More information about the Python-list mailing list