[Python-3000] Using range()
Facundo Batista
facundobatista at gmail.com
Thu Apr 24 17:08:13 CEST 2008
2008/4/24, "Martin v. Löwis" <martin at v.loewis.de>:
> The advanced way of invoking some method on the object (i.e. emulating
> the for loop) is to first create an iterator from the range object.
> You can't consume the range itself: it will always contain the same
> numbers - just like you can't consume a list.
Great! Thanks!
>>> r = range(10000000000000000000)
>>> it = iter(r)
>>> it.__next__()
0
>>> it.__next__()
1
> >>>> 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?
>
> I'd call it an implementation limitation.
This is because I'm in a 32 bit machine?
>>> n = 10000000000000000000
>>> 2**32 > n
False
>>> 2**64 > n
True
Should it work in a 64 bit hardware?
Thanks again!
--
. Facundo
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
More information about the Python-3000
mailing list