(x)range( 40000000000, 40000000001 )

Aahz aahz at pythoncraft.com
Sun Jun 29 21:10:11 EDT 2003


In article <3eff347f$1 at buckaroo.cs.rit.edu>,
Chris Connett  <kill_cxc_spam_0117 at cs.rit.edu> wrote:
>
>It seems range and xrange don't like longs that can't be sqeezed into ints:
>
>With Python 2.3b1+:
>
> >>> xrange( 40000000000, 40000000001 )
>Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>OverflowError: long int too large to convert to int
> >>> range( 40000000000, 40000000001 )
>Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>OverflowError: long int too large to convert to int
> >>>

The first problem is that range is designed to create a list and the
canonical usage for range is range(N); lists cannot currently have more
than int elements.  xrange() could get away with fixing it, but Guido has
decreed that xrange() is a target for deprecation (and will go away in
Python 3.0), so he won't allow any improvements to xrange() in order to
encourage people to use alternatives.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Usenet is not a democracy.  It is a weird cross between an anarchy and a
dictatorship.  




More information about the Python-list mailing list