print "foo", without a space
Tim Peters
tim_one at email.msn.com
Fri Nov 12 00:04:47 EST 1999
[Mikael Johansson]
> Is there another way of getting print to not make a newline than
> using:
> print "foo", ?
No.
> This because the comma always produces a space which necessary
> isn't that nice ...
That's a different issue than newlines. In small doses, this devious trick
is quite pleasant:
>>> import sys
>>> def no_space_before(x):
sys.stdout.softspace = 0
return x
>>> ns = no_space_before
>>> print 1, ns(2), 3, ns(4), 5
12 34 5
>>>
the-great-thing-about-python-is-it's-so-obvious<wink>-ly y'rs - tim
More information about the Python-list
mailing list