Conversion to string: how do `s work?

Chris Lasher chris.lasher at gmail.com
Mon Mar 14 15:15:32 EST 2005


I'm working my way through _Learning_Python_ 2nd ed., and I saw
something peculiar which is not explained anywhere in the text.

print " " + file + " size=" + `size`

The `s appear to somehow automagically convert the integer to a string
for concatenation. How does this work? Is this just a shortcut for
str(size)? Is it considered bad practice to use `s?




More information about the Python-list mailing list