int() shortcoming?

John Roth johnroth at ameritech.net
Sat Nov 23 08:29:59 EST 2002


"Matthew Knepley" <knepley at mcs.anl.gov> wrote in message
news:y8h3cptpttf.fsf at spinetta.mcs.anl.gov...
>        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.

To whom is this clear? For me, it is one of the many idiocies
foisted off on a gullable programming community by the inventors
of the 'c' programming language (although it may have deeper
roots.)

In other words, what's "clear" depends on your background. The
numeric literal syntax is not at all clear to a novice; it's simply an
idiom that they have to learn.

John Roth
>
>     Thanks,
>
>         Matt
> --
> "Failure has a thousand explanations. Success doesn't need one" -- Sir
Alec Guiness





More information about the Python-list mailing list