Conversion to string: how do `s work?

Michael Hoffman cam.ac.uk at mh391.invalid
Mon Mar 14 15:32:21 EST 2005


Chris Lasher wrote:

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

No, it's a shortcut for repr(size).

> Is it considered bad practice to use `s?

Yes, please don't do it. I can't remember ever seeing it in production
code, so many people wouldn't even know what it was. And ' vs. ` is
confusing.
-- 
Michael Hoffman



More information about the Python-list mailing list