print, softspace, and stdout -- Newbie

Brandon Irons brandonirons at topmail.de
Wed May 24 12:46:08 EDT 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:
ab

  I've even tried:
sys.stdout.close()
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?

  TIA.

 oBrando



More information about the Python-list mailing list