[Tutor] os module continued

Remco Gerlich scarblac@pino.selwerd.nl
Thu, 26 Oct 2000 22:03:22 +0200


On Thu, Oct 26, 2000 at 03:53:04PM -0400, D-Man wrote:
> 
> That's one solution.  
> Another is to convert x to a string:
> 
> s = "Added /fake/structure/log" + `x`
> 
> or
> 
> s = "Added /fake/structure/log" + str( x )
> 
> 
> The backquotes in the first example are a shortcut to call the str() funciton in the second example.

Actually, the backquotes call repr(), which is often subtly different
from str(). str() is meant to be seen by users, whereas repr() is meant
as a representation that could be used by Python (eval(repr(x)) == x,
ideally).

Compare repr() and str() of a string, or of a floating point number in
1.6 or 2.0...

-- 
Remco Gerlich