my first real program blows up, can someone tell me why?

Justin Sheehy dworkin at ccs.neu.edu
Sun Mar 5 18:15:28 CET 2000


"Jerry F. Davis" <jfdecd at execpc.com> writes:

> I read the tutorial and tried a variation on what i saw there. and it
> blew up, with a integer overflow. can someone tell me why?

You aren't converting the argument to a string.

The line that reads:

x = sys.argv[1]

should read:

x = int(sys.argv[1])

With that change, your program should only overflow if you try to pass 
an argument that is... hm, one larger than the last fibonacci number
preceding your system's maximum integer.

If you wish to make your program able to handle arbitrarily large
arguments, you should modify it to use Python's long data type.

-Justin

 




More information about the Python-list mailing list