[Tutor] running more than one python program at the same time

William R. Wing (Bill Wing) wrw at mac.com
Mon Sep 3 18:26:27 CEST 2012


On Sep 3, 2012, at 11:01 AM, Benjamin Fishbein <bfishbein79 at gmail.com> wrote:

> Hi. I started running the program in the terminal rather than IDLE. It works, and I can run several programs at the same time. The problem is that when the program is finished running, it prints:
> exit status: 0
> logout
> 
> [Process completed]
> 
> And I can't access the data that the program returned. Do I need the program to be saved to a text file, or is there a way to simply print it out? It's a small amount of data, and I'd rather just print it out.
> Ben
> 

Ben, You will probably get several answers to this, since there are several ways to solve the issue.  The simplest (sort of kludgy) solution is simply to make the last line in your program be:

junk = raw_input("Yes Master?")

and when your program hits this line, it will print out "Yes Master?" in the terminal window and then sit there waiting for you to type something terminated by a <return> key.  For future reference, what you've typed goes into the variable junk.  This is a dead easy way to get interactive data into ANY future python script you write.

-Bill

PS:  this assumes you are running python 2.x.  In python 3.x, raw_input has been renamed input, but it works the say way.



More information about the Tutor mailing list