[issue11633] regression: print buffers output when end=''

Terry J. Reedy report at bugs.python.org
Tue Mar 22 23:44:13 CET 2011


Terry J. Reedy <tjreedy at udel.edu> added the comment:

Python 3.2, WinXP, IDLE edit window, F5 Run:
'Processing ...' appears immediately, 'Done' 3 sec later.
The only difference between printtest2/3 is where 'Done' appears.

Behavior is same when pasting into interactive interpreter -- has to be since the first two prints are executed before the sleep. I presume interpreter flushes before or after printing next prompt. IDLE must do same even when running from editor even when not printing prompts.

Anatoly, I gather you ran files by some other method.

I disagree with closing this yet. Print was designed to be a simplified wrapper around sys.stdout.write (and now, any file.write). Requiring that one import sys to use print goes against that.

I have always experienced and expected Python's print to screen to be immediately visible. I thought that was pretty standard in other languages with a print-to-screen separate from general file-write. When printing to screen, efficiency is, I believe, a non-issue. Writing to files or the net is a whole different ballgame.

Amaury's idea of checking isatty seems good. Otherwise, print should gain an optional, no-default flush=True/False parameter (no default because behavior currently varies.) Until then, non-flushing *should* be documented. The current doc for print does not seem to address the issue either way.

Amaury, I though 'run from console' more or less meant 'isatty', so I am not sure I understand your comment.

----------
assignee:  -> docs at python
components: +Documentation, Library (Lib)
nosy: +docs at python, terry.reedy
resolution: invalid -> 
status: closed -> open
type:  -> feature request
versions: +Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11633>
_______________________________________


More information about the Python-bugs-list mailing list