Newbie: Casting Int to string....

David Bolen db3l at fitlinxx.com
Thu Mar 1 20:16:26 EST 2001


joconnor at cybermesa.com writes:

> Yes, it is :)
> 
> You can  do either....
> 
> 	nntp.stat (str(aNumber))
> 
> or teh shorter
> 	nntp.stat (`aNumber`)
> 
> Notice that the single quotes are backwards

Note that for an single solitary number, this will yield the same
results, but under the cover, str() is using __str__ (or the
equivalent for built-ins) whereas backquotes (``) are a short form of
repr() which uses __repr__.  So while the two the methods will both
yield a string, it may not be the same string value depending on the
objects involved.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list