On 2021-01-15, Alan Gauld via Python-list <python-list@python.org> wrote: > On 15/01/2021 17:31, Grant Edwards wrote: > >> I suspect that the problem is that putp is writing to the libc >> "stdout" FILE stream that's declaredin <stdio.h>. That stream >> layer/object has buffering that is invisible to Python. > > That would indeed explain it. > >> Now the question: is there a way to tell the curses module to flush >> its stdout FILE stream? > > Indeed. But unless it's trivial it rather defeats the concept of > using the terminfo functions to create text effects without > diving into full curses screen control!
Indeed, that appears to be the case for Python 3.x (unless we can figure out a way to flush <stdio.h>'s FILE *stdio stream from Python). I started a separate thread about that specific topic. > And that was what I was hoping to uncover. > > I wonder if I can use the os module to mess with the > file descriptors.... hmmm. > > Thanks for that snippet, I had no idea that input() wrote > to stderr nor that Python added a stdout layer on top of libc. Just to be clear, Python 3.7+ stdio,stdin,stderr layers are _not_ on top of libc's FILE *stdout, stdin, stderr streams and share nothing with them other than the spelling of the names and (by default) the underlying file descriptors. Python's input/output layers are on top of file descriptors 0, 1, 2. Older versions of Python had I/O layers that were on top of libc's FILE *stdin, *stdout, *stderr. > Do you know where that is documented? I'd be interested in > reading more. I can't find it at the moment. Unfortunately words like "file" and "stream" are too common for Google. -- https://mail.python.org/mailman/listinfo/python-list