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

Alexander Belopolsky alexander.belopolsky at gmail.com
Fri Oct 3 18:32:14 CEST 2014


On Fri, Oct 3, 2014 at 12:27 PM, Ian Cordasco <graffatcolmingov at gmail.com>
wrote:

> > Builtin range is not a generator.
>
> It is on Python 3 (but not Python 2):
>
> $ python3
> >>> range(100000)
> range(0, 100000)
>
> And I assumed that most discussion for Python-ideas pertained to
> features for Python 3, am I incorrect in that?


You are correct about python-ideas, but range is not a generator in python
3 either:

Python 3.4.0a0 (default:e9cecb612ff7+, Oct  3 2014, 12:07:42)
>>> type(range(10))  # not a generator
<class 'range'>
>>> type(x for x in range(10))  # a generator
<class 'generator'>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141003/5626855a/attachment.html>


More information about the Python-ideas mailing list