I made the following script which is almost the same as available here.
from multiprocessing import Process
import time
import sys
def f(n):
print n
# sys.stdout.flush()
if __name__ == '__main__':
f('hello')
p = Process(target = f, args=('python',))
p.start()
p.join()
time.sleep(2)
print 'bye'
When i run the script in python IDLE, it outputs :
hello
bye
and not :
hello
python
bye
But when i run the script in windows terminal it gives the required output. Following the advice here, i tried sys.stdout.flush()
as I thought there would be some buffering issues.
How can I get the desired output in the python shell ? Any suggestion is appreciated. I am using Python 2.7.9 [MSC v.1500 64 bit (AMD64)] on win32.
EDIT:
I went through the question suggested in the comment. I ran the command python -m idlelib.idle
as suggested from the terminal but it opened a python console and a shell. I ran my script through this shell but still the output was shown on the console and not the shell.
How can I get the output on the shell directly so that i don't have to run the script from terminal every time when i have to debug using print statement ?