Overflow error when printing long values

Michael Teo michaelteo at bigfoot.com
Fri Aug 31 02:43:53 EDT 2001


Thanks for your help.
However, I noticed that Python 2.1 does not give a trailing 'L' for str(l).
Is there any solution which will work well for Python 1.5.2 and Python 2.1 ?

On Thu, 30 Aug 2001 23:51:25 +0800, Paul Rubin <phr-n2001 at nightsong.com> wrote:
>michaelteo at bigfoot.com (Michael Teo) writes:
>> I get an "OverflowError: long int too long to convert" when I tried to 
>> print "%d" % l
>> where l is a long Python value.
>> 
>> I have tried using str(l) but that gives a trailing 'L'.
>> 
>> Any good suggestion on how to solve this problem will be greatly
>> appreciated. Thanks.
>
>print str(l)[:-1]


-- 
Michael Teo <mailto:michaelteo at bigfoot.com>
http://miketeo.net/
PGP  0x6C846A9C  DB:7D:51:D4:4D:AB:97:79:E4:68:D9:07:94:36:D5:1A:6C:84:6A:9C
     0x6937FB05  08:50:A1:4D:2E:45:58:60:DE:71:1F:30:63:54:EF:7B




More information about the Python-list mailing list