Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
3  
Try python -u to run in an unbuffered mode. stackoverflow.com/questions/230751/… –  jdigital Jan 24 '12 at 23:44
    
@user8368 - Thanks, that worked perfectly. –  Abiel Jan 25 '12 at 2:01

1 Answer 1

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.

share|improve this answer
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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