sys.stdout question

M.E.Farmer mefjr75 at hotmail.com
Mon May 2 17:31:17 EDT 2005


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  after a print "dsfdfdssd",
if the shell didn't add the \n to get it there.
Also note most shells use repr or str behind the scenes for output to
sys.stdout sys.stderr.
>>> def g():
...     pass
...
>>> g # notice it has been repr'd for you
<function g at 0x0077AB88>
>>> repr(g)
'<function g at 0x0077AB88>'
M.E.Farmer




More information about the Python-list mailing list