scanf in python...?

Andrew Dalke dalke at acm.org
Mon Oct 23 15:48:50 EDT 2000


Grant Griffin wrote:
>There's a subtle thing going on here that I think the FAQ entry should
>be revised to explain.  ... [Differences between string.atoi and int
> and string.atof and float] ... [atoi not taking 0x without a base].

Yes, there are differences between int/float and string.atoi/atof.  As
I recall, the differences used to be greater - one of those pairs was
pickier than the other regarding the number format?  But now they are
migrating to become the same thing, so that the string module can be
deprecated.

Regarding the leading "0x", use a base of 0 to say that the string
specifies its own base

>>> string.atoi("0x10", 0)
16
>>>

See http://www.python.org/doc/current/lib/module-string.html

BTW, this is all vague memories merged tied together to approximate a
guess.  Consult the powers that be for a more specific answer, esp. if
you want more historical context.

                    Andrew
                    dalke at acm.org








More information about the Python-list mailing list