string to big int

Andrew Koenig ark at
Sat Aug 31 18:41:21 CEST 2002

Axel> Hi, Im wondering how to convert a string which contains a huge integer
Axel> ("10000000000007") to a real integer (type int). When I ask int() to
Axel> this it replies:

Axel> Traceback (most recent call last):
Axel>    File "C:\", line 43, in ?
Axel>      main()
Axel>    File "C:\", line 29, in main
Axel>      no = int( argv)
Axel> ValueError: int() literal too large: 10000000000007

Axel> any ideas?

You can't represent 10000000000007 as an int in most Python
implementations, so use a long instead:

        >>> long("10000000000007")

Andrew Koenig, ark at,

More information about the Python-list mailing list