I'm using Notepad++'s NppExec plugin to execute Python scripts from within Notepad++. I notice that Python console output produced with the print()
statement doesn't appear on the Notepad++ console until the entire script is finished executing. Is there a way to make print statements appear in real-time?
I'm using Notepad++ v.5.9.8 and NppExec v0.4.1.
Best Answer
The console window of NppExec is started as a child process, meaning that updating the display of the console window, as well as running the main program, are carried out on a single thread. By default, Python print statement outputs are buffered and run on the same thread as the parent script, so the output has to be displayed in unbuffered mode. This is done with the
-u
flag.Use
python -u script.py
instead of the conventionalpython script.py
, as can be seen in this SO question.