4

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.

4

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 conventional python script.py, as can be seen in this SO question.

  • 1
    To prevent your script's own windows being suppressed (not sure exactly what is going on here), run the call to Python as an argument to cmd by preprending cmd /c. For example, I'm using cmd /c python -u "$(FULL_CURRENT_PATH)" so my Cocos2D window shows up. – Eric Jun 21 '12 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.