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

Trent Mick trentm at ActiveState.com
Thu Feb 10 17:17:40 CET 2000


'print's behaviour is, I believe, in the spirit of "make the most common
task easy". If you want finer control, e.g. not printing the space, then
use:

import sys
sys.stdout.write('my string')   # no trailing newline or space

Trent

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Peter Bittner
> Sent: Thursday, February 10, 2000 11:47 PM
> To: python-list at python.org
> Subject: How to get rid of the space after 'print',?
> Importance: High
>
>
> 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??
>
> Please, e-mail!
>
> Kipis!    # I don't know the Nederlands' "cheers", sorry!  :o)
> Peter
>
> | Peter H. Bittner
> | International Student at Aston University
> | e-mail: bittneph at aston.ac.uk
> | web: http://beam.to/bimbo
> +--------------------------
> --
> http://www.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list