[Python-ideas] Make len() usable on a generator

Joshua Landau joshua at landau.ws
Fri Oct 3 19:13:20 CEST 2014


On 3 October 2014 17:45, Ian Cordasco <graffatcolmingov at gmail.com> wrote:
> On Fri, Oct 3, 2014 at 11:32 AM, Alexander Belopolsky
> <alexander.belopolsky at gmail.com> wrote:
>> On Fri, Oct 3, 2014 at 12:27 PM, Ian Cordasco <graffatcolmingov at gmail.com>
>> wrote:
>>>
>>> > Builtin range is not a generator.
>>
>> You are correct about python-ideas, but range is not a generator in python 3
>> either:
>
> Ah yeah. All too often I conflate lazy iterators with generators. Nevermind

It's not an iterator either:

    from collections.abc import Iterator
    isinstance(range(10), Iterator)
    #>>> False

It's just an iterable container.


More information about the Python-ideas mailing list