Long int too large to convert?

Markus Schaber markus at schabi.de
Thu Sep 13 19:17:10 CEST 2001


Hi,

fbasegmez <fb at ultranet.com> schrub:

> I thought the xrange could handle the long integers. Then I tested it
> 
>>>> for i in xrange(eval(200*'9'+'L'), eval('1'+200*'0'+'L')):
> ...   print i
> ...
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
> OverflowError: long int too large to convert
> 
> My first question was; too large to convert to what?  Now I realize
> (thanx to your response) that range or xrange is trying to convert the
> long integers to integers.  I think I would be less surprised if I got
> 
>>>> for i in xrange(1L, 10L):
> ...   print i,
> ...
> Error. xrange start and stop values must be integer.  Or something
> like that.

I just agree to this, changeing the message to something like
> OverflowError: long int too large to convert to integer
would make it definitely much more readable.

Although I don't see any reason (other than easier implementation) to 
allow long ints here, and hope for the upcoming int/long unification in 
this point.

markus
-- 
"The strength of the Constitution lies entirely in the determination of 
each citizen to defend it. Only if every single citizen feels duty 
bound to do his share in this defense are the constitutional rights 
secure." -- Albert Einstein



More information about the Python-list mailing list