print, softspace, and stdout -- Newbie

Brandon Irons brandonirons at
Wed May 24 18:46:08 CEST 2000

  I can't get softspace to take effect for sys.stdout.  I have tried:
sys.stdout.softspace = 0
print 'a'
print 'b'

  with the result:
a b

I can get the result I want using write():
sys.stdout.write( 'a' )
sys.stdout.write( 'b' )

  with the desired result:

  I've even tried:
sys.stdout.softspace = 0
# then I couldn't figure out how to reopen sys.stdout

  Since the softspace attribute was made writeable, it seems to me
there must be a way to get this output using print and softspace.
What is it?

  My second question is: In that last code snippet, how would I go
about re-opening stdout?



More information about the Python-list mailing list