How to get rid of the space after 'print',?

Gary Herron gherron at aw.sgi.com
Fri Feb 11 01:10:08 CET 2000


Peter Bittner wrote:
> 
> Hi there!
> 
> I'm writing HTML-code with the print statement as follows:
> 
>   print '<table border=0><tr>'
>   print '<td><b>Author:</b></td><td>',   # ,= no newline here
>   print '<input ...>'         # or put a function call here...
> 
> Between <td> and <input> I want _no_ space, but Python automatically
> inserts one. - How can I force Python not to do this??
> 

Easy, write to stdout directly:

import sys
sys.stdout.write(SomeString)

This writes out the bytes of the string exactly, nothing more, nothing
less.  No following spaces, no line-ends, and no conversion from other
types, just (binary) byte strings.

Gary.

-- 
Dr. Gary Herron <gherron at aw.sgi.com>
206-287-5616
Alias | Wavefront
1218 3rd Ave, Suite 800, Seattle WA 98101




More information about the Python-list mailing list