sys.stdout question
chris patton
chrispatton at gmail.com
Sun May 1 18:18:59 EDT 2005
>>> import sys
>>> class stuff:
... things = []
... def write(self, string):
... self.things.append(string)
...
>>> def_stdout = sys.stdout
>>> sys.stdout = stuff()
>>> print 'this is a string.'
>>> print 'This is another string.'
>>> sys.stdout = def_stdout
>>> print stuff.things
['This is a string.', '\n', 'This is another string.', '\n']
Where are the newline characters coming from?
More information about the Python-list
mailing list