Using print with format to stdout generates unwanted space

Michael Hoffman cam.ac.uk at mh391.invalid
Tue Jun 21 11:33:08 EDT 2005


[Tim Williams]
>>For quick and simple removal of the extra space,  append a '\b'
>>backspace character to your output "string"

[Jorgen Grahn]
> For things that are only ever to be viewed on the terminal, yes.
> But this does, of course, print an actual backspace character.
> If you feed this output to another program, chances are it will
> not treat <space><backspace> as no space at all.
> 
> I prefer building up a list and doing ' '.join(thelist) in these situations.

A much better approach. Or you can use sys.stdout.write() as others have 
said.
-- 
Michael Hoffman



More information about the Python-list mailing list