What a weird thing !!?

Michael Hudson mwh21 at cam.ac.uk
Sat Feb 19 03:50:04 EST 2000

"Florent Ramière" <framiere at netcom-service.com> writes:

> Thanks for your answers,
>     in fact as Moshe Zadka told me, it is a documented feature ... (sorry)
>     Well, i should have read more carefully the doc (re-sorry)
>     And is there a solution to my problem ?
>     And sys.stdout.write is not a good solution for me (i need to keep
> printing with print)
>     Is there an easy way to override the print statement (i saw it one time
> in the news, but i can not find it)

You want sys.stdout.softspace:

>>> print 1,;print 2
1 2
>>> print 1,;sys.stdout.softspace=0;print 2

It's a bit tedious to actually use, as it keeps getting reset; you
could try this:

>>> class SF:
...  def __init__(self,string): self.string = string
...  def __str__(self): sys.stdout.softspace = 0; return self.string
>>> print SF("2"),1


More information about the Python-list mailing list