[Python-3000] print() flushing problem.

Wojciech Walczak wojtek.gminick.walczak at gmail.com
Wed Nov 7 13:59:35 CET 2007


Hello,

py3k's print() is not flushing when end is set to '' and all it has to
print is one-character-long string:

Python 3.0a1 (py3k, Nov  6 2007, 19:25:33)
[GCC 4.1.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print('x',end='')
>>> print('')
x
>>> print('',end='x')
>>> print('')
x
>>>


It works OK, when string is longer than 1:
>>> print('xx',end='')
xx>>>
>>> print('',end='xx')
xx>>>

When end is not set at all, it is flushing allright, because print()
prints '\n' at the end:
>>> print('x')
x
>>>

What's even stranger - it's sensitive for spaces (or it's just coincidence)
in the strings:
>>> ret=[print(i,end='') for i in list('print is not flushing')]
print is not flushin>>>
>>> print()
g
>>>ret=[print(i,end='') for i in list('printisnotflushing')]
printisnotflushing>>>

>>> for i in list('print is not flushing'):
...    print(i,end='')
...
print is not flushin[3.0a1]>>> print()
g
>>> for i in list('printisnotflushing'):
...    print(i,end='')
...
printisnotflushing>>>


My proposition of patch is in the attachment, but I think that the
problem lies somewhere deeper.


I was testing both bug and patch on Slack 12 and Debian Etch.


Wojtek Walczak
-------------- next part --------------
A non-text attachment was scrubbed...
Name: py3k-print.patch
Type: application/octet-stream
Size: 805 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-3000/attachments/20071107/43c5b408/attachment.obj 


More information about the Python-3000 mailing list