Message131800
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. |
|
Date |
User |
Action |
Args |
2011-03-22 22:44:13 | terry.reedy | set | recipients:
+ terry.reedy, amaury.forgeotdarc, vstinner, techtonik, docs@python |
2011-03-22 22:44:13 | terry.reedy | set | messageid: <1300833853.79.0.644803146039.issue11633@psf.upfronthosting.co.za> |
2011-03-22 22:44:12 | terry.reedy | link | issue11633 messages |
2011-03-22 22:44:12 | terry.reedy | create | |
|