int() shortcoming?

Alex Martelli aleax at aleax.it
Fri Nov 22 09:56:41 EST 2002


Matthew Knepley wrote:

>        Is there a reason I should have to specify the base for a string
> conversion using int() when it is already clear from the form? For

Yes: the reason is the default is to use base 10.  If you want int to
figure out what base to use (8, 10, or 16) based on the form of the string,
pass 0 as the second parameter to int.


Alex




More information about the Python-list mailing list