Probably a stupid newbie question....i got to ask

Peter Hansen peter at
Thu Aug 9 04:17:19 CEST 2001

fett at wrote:
> How do you use string.atoi to convert a variable integer to a string?
> I have tied theese different ways...
> daverse = string.atoi(daverse)
> daverse = string.atoi(), daverse
> daverse = string.atoi("daverse")

You don't, for several reasons. :)

string.atoi() has been deprecated since release 2.0.  
Don't use it unless you're using an older version of Python.
(The replacement, as documented in the global module 
index for module "string", is the built-in int().)

The other reason you don't, is that string.atoi (and int())
converts strings which contain ASCII representations of
integers to the integer value, not the other way around.

You are probably looking for this answer, from the FAQ
(which I recommend you read thoroughly):

(A last suggestion: when posting questions like this,
I recommend you type your experiments in the interactive
interpreter, and when they don't work out, cut and
paste the *entire* sequence (including the exceptions!)
into your posting.  This will make it a lot easier for
people to figure out what you really want to do, and
why what you tried didn't work.)

Peter Hansen, P.Eng.
peter at

More information about the Python-list mailing list