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
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
I tried adding the comma at the end
print 'hello',
It still added that extra character.
--
http://mail.python.org/mailman/listinfo/python-list
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
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.
>>> 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