print and trailing white space
__peter__ at web.de
Fri Sep 19 00:15:50 CEST 2003
Maxime Biais wrote:
> I know how to print a string without the trailing newline with a coma
> like :
> print "hello word",
> but this example add a white space after the string :(
> Do you know how to avoid this white space without using write()
>>> class Out(object):
... def _set_softspace(self, value):
... def _get_softspace(self):
... return False
... softspace = property(_get_softspace, _set_softspace)
... def write(self, s):
>>> out = Out()
>>> print >> out, "a", "b", "c"
>>> print >> out, "x",
It's possible, but I'd rather go with write().
And, please, never ever substitute sys.stdout with a similar object.
More information about the Python-list