Newbie: Casting Int to string....

joconnor at cybermesa.com joconnor at cybermesa.com
Thu Mar 1 18:31:47 EST 2001


On Thu, 1 Mar 2001 18:01:09 -0500, "Digital Hyakugei"
<jos at trapeze.removespam.com> wrote:

>Ok, pretty simple, no? I can not find out how to do the following...
>
>i've got a variable:
>
>aNumber = 1
>
>Now i have a function
>
>nntp.stat( aVal )
>
>where aVal has to be a string.
>
>I cant do
>
>nntp.stat( aNumber )
>
>cuz it expects a string, not an int.
>
>How, oh how, do i cast an int to a string?
>I'm sure its something that is forehead slapping obvious, but i just cant
>seem to find it...
>


Yes, it is :)

You can  do either....

	nntp.stat (str(aNumber))

or teh shorter
	nntp.stat (`aNumber`)

Notice that the single quotes are backwards

Take care,
Jay O'Connor



More information about the Python-list mailing list