What should go to stdout/stderr and why Python logging write everything to stderr?
Chris Angelico
rosuav at gmail.com
Wed Jan 4 00:46:37 EST 2023
On Wed, 4 Jan 2023 at 15:11, Eryk Sun <eryksun at gmail.com> wrote:
>
> On 1/3/23, Chris Angelico <rosuav at gmail.com> wrote:
> >
> > writing the FD is the same as using stdout
>
> Except stdout may be buffered. One should probably flush the buffer
> before each raw write to the file descriptor.
FDs can also be buffered. If it's buffering you want to avoid, don't
mess around with exactly which one you're writing to, just flush.
> > use /dev/tty to reach for the console directly.
>
> On Windows, open "CON" (read or write), "CONIN$" (read-write), or
> "CONOUT$" (read-write). Or use the more explicit device paths
> "\\.\CON", "\\.\CONIN$", and "\\.\CONOUT$". If the process has no
> console, one can call WinAPI AllocConsole() or
> AttachConsole(process_id) to obtain one.
Yeah, /dev/tty is the Unix option, Windows has its own way, but
whatever platform you're on, there's a way to directly reach the
console.
ChrisA
More information about the Python-list
mailing list