Chris Lasher wrote:

> 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?

In addition to the fact that `` is repr() and generally shouldn't be
used, the above is much better written using string formatting:

    print ' %s size=%u' % (file, size)

Shorter, cleaner, and more explicit.

Tim Delaney
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to