"print int" would be nice

Max M maxm at mxm.dk
Thu Jan 24 07:30:46 EST 2002


Thomas Guettler wrote:

> Is there a reason why python doesn't convert a int to string 
> automatically? Would be nice this would work:
> 
> i=2
> print "int: " + i

You will be a lot happier if you get used to not using + for 
concatenating strings.

use

     print "int: %s" % i

instead.

that wil automatically try to convert all input to a string.

regards Max M




More information about the Python-list mailing list