print ending with comma

jamesthiele.usenet at jamesthiele.usenet at
Tue Jul 19 17:36:16 CEST 2005

I recently ran into the issue with 'print' were, as it says on the web
page called "Python Gotchas"

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 '-',
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?

More information about the Python-list mailing list