[Python-3000] Using range()
Facundo Batista
facundobatista at gmail.com
Thu Apr 24 16:40:33 CEST 2008
Hi all!
Used to be able to do this...
>>> l = (x for x in range(10))
>>> l.__next__()
0
>>> l.__next__()
1
...I tried the following:
>>> r = range(5)
>>> r
range(0, 5)
>>> r.__next__
Traceback (most recent call last):
...
AttributeError: 'range' object has no attribute '__next__'
Which is the normal way to "consume" a range object, item by item?
Furthermore, I took a look inside, and found a __getitem__, so I tried
>>> r[4]
4
which apparently works, but see:
>>> r = range(10000000000000000000)
>>> r[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t
>>>
This is a bug, right?
Thank you very much!!
Regards,
--
. Facundo
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
More information about the Python-3000
mailing list