J
jamesthiele.usenet
I recently ran into the issue with 'print' were, as it says on the web
page called "Python Gotchas"
(http://www.ferg.org/projects/python_gotchas.html):
The Python Language Reference Manual says, about the print statement,
A "\n" character is written at the end, unless the print statement ends
with a comma.
What it doesn't say is that if the print statement does end with a
comma, a trailing space is printed.
--
But this isn't exactly correct either. If you run this program:
import sys
print '+',
print '-',
sys.stdout.write('=')
print
--
the output is:
+ -=
Note that there is no space after the '-'. (Tested on Win 2000 python
2.3.4, OS X 10.3.9 python 2.3 & 2.4)
I know that this is not a massively important issue, but can someone
explain what's going on?
page called "Python Gotchas"
(http://www.ferg.org/projects/python_gotchas.html):
The Python Language Reference Manual says, about the print statement,
A "\n" character is written at the end, unless the print statement ends
with a comma.
What it doesn't say is that if the print statement does end with a
comma, a trailing space is printed.
--
But this isn't exactly correct either. If you run this program:
import sys
print '+',
print '-',
sys.stdout.write('=')
--
the output is:
+ -=
Note that there is no space after the '-'. (Tested on Win 2000 python
2.3.4, OS X 10.3.9 python 2.3 & 2.4)
I know that this is not a massively important issue, but can someone
explain what's going on?