Temporally disabling buffering

Barry barry at barrys-emacs.org
Thu Mar 31 13:23:40 EDT 2022



> On 31 Mar 2022, at 17:39, Cecil Westerhof via Python-list <python-list at python.org> wrote:
> 
> In Python when the output of a script is going to a pipe stdout is
> buffered. When sending output to tee that is very inconvenient.
> 
> We can set PYTHONUNBUFFERED, but then stdout is always unbuffered.
> 
> On Linux we can do:
>    PYTHONUNBUFFERED=T script.py | tee script.log
> 
> Now the output is only unbuffered for the current run and buffered for
> other runs where the output goes to a pipe.

I prefer to use the -u when I run the output of python into the.

python -u script.py | tee script.log

And use py -u on windows.

Barry

> 
> -- 
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list