As pointed in a comment you are seeing the effects of line buffered standard output in Python 2.x: a trailing ,
in a print
will prevent it to emit a new line. The text with the trailing ,
will not be printed before a new line is emited. You can remove the buffering with some simple code:
#!/usr/bin/env python
import sys
class Logger(object):
def __init__(self, stream):
self.stream = stream
def write(self, msg):
self.stream.write(msg)
def flush(self):
pass
if __name__ == '__main__':
sys.stdout = Logger(sys.stdout)
print 'User says hello!',
print 'Goodbye, cruel world!'
As you see sys.stdout
is replaced with other stream which does a flush
after every print. You can also see this thread and this one for more information.