Re: running python script with [command] outputs info only when script exits

Chris McCormick <[email protected]>
Newsgroups gmane.comp.multimedia.puredata.general
Message-ID <[email protected]>
On 10/12/2024 10:31, Roman Haefeli wrote:
> It seems that Python's "print" buffers its output per default.


You can also disable output buffering entirely in a few different ways 
if you don't want to explicitly put flush in every print statement:

1. Use the `-u` command line switch
2. Wrap sys.stdout in an object that flushes after every write
3. Set `PYTHONUNBUFFERED` env var
4. `sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)`

<https://stackoverflow.com/questions/107705/disable-output-buffering>


Cheers,

Chris.

-- 
https://mccormick.cx/

---
[email protected] - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/[email protected]/message/TCENWEVTMVW2HJ5I2FNBMZFLI4CVEXEV/

To unsubscribe send an email to [email protected] mailing list
UNSUBSCRIBE and account-management -> https://lists.iem.at/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.