piranha/opster — pull request #46 by oscarbenjamin (2012-06-16 20:15:28+00:00)
Title: Use print for output

This patch is for #44.

All tests pass on Python 2 and 3 on both Linux and Windows.

At first I though I could use

print >> out, msg,

to supress newlines but it turns out that Python 3 does not have a precise equivalent for the trailing comma `print` statement or at least the 2to3 tool does not produce one. This is because Python 3's `print` function lacks the 'soft-space' feature of Python 2's `print` statement. So if we have

print >> out, 'text\n',

then 2to3 gives us

print('text\n', end=' ', file=out)

which produces a trailing space after the newline e.g. ```'text\n '```. I had to remove the newlines to use the ordinary `print` statement that 2to3 and Python 3 can handle correctly.