[Tutor] Space

Remco Gerlich scarblac@pino.selwerd.nl
Mon, 18 Mar 2002 02:41:29 +0100


On  0, Grail <python@nzpagans.8m.com> wrote:
> At http://starship.python.net/~da/jak/cookbook.html
> It says
> "In python, the print statement has very good default semantics --- most of the time, it does exactly what you want, putting a space between the arguments, and a newline at the end. If you want more control over the formatting, use the % operator [link to % operator]: rather than 
>     print k, ':', string.join(v)
> 
> you could use 
> print "%s: %s", (k, string.join(v))
> 
> to avoid the space before the colon."

This should read 

print "%s:%s" % (k, string.join(v))

Note the % (and the absence of the space in the string - otherwise there
will still be a space there...

-- 
Remco Gerlich