int() shortcoming?
Padraig Brady
Padraig at Linux.ie
Fri Nov 22 09:45:13 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 instance:
>
>>>>oct(15)
>>>
> '017'
>
>>>>int('017')
>>>
> 17
>
>>>>int('017', 8)
>>>
> 15
>
> and hexidecimal actually generates an error.
I agree with you somewhat.
I think int() be default should behave like strtol(nptr, (char **)NULL, 0)
rather than strtol(nptr, (char **)NULL, 10);
However this is not backwards compatible.
I.E. int('017') would give a different answer.
see also:
http://tardis.redbrick.dcu.ie/391/groups.google.com
Pádraig.
More information about the Python-list
mailing list