Re: sys.stdout question

2005-05-02 Thread Peter Otten
chris patton wrote: > I tried adding the comma at the end > print 'hello', > It still added that extra character. http://mail.python.org/pipermail/python-list/2003-September/184181.html Peter -- In diesen Kreisen kreiselt sich der Kreisler -- http://mail.python.org/mailman/listinfo/python-li

Re: sys.stdout question

2005-05-02 Thread M.E.Farmer
Save your script and run that from a commandline or import it with your python shell. ['this is a string.', ' ', 'This is another string.'] You are seeing a side effect of the interactive shell. ['this is a string.', '\n', 'This is another string.','\n'] It would be hard to get to the next prompt

Re: sys.stdout question

2005-05-02 Thread chris patton
I tried adding the comma at the end print 'hello', It still added that extra character. -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout question

2005-05-01 Thread M.E.Farmer
Print is the culprit here. Note item 2. >>> help('print') 6.6 The print statement print_stmt::="print" ( [expression[1] ("," expression[2])* [","]] | ">>" expression[3] [("," expression[4])+ [","]] ) Download entire grammar as text.[5] print e

Re: sys.stdout question

2005-05-01 Thread Steve Holden
chris patton wrote: 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.

sys.stdout question

2005-05-01 Thread chris patton
>>> 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 stuf