[Tutor] program spontaneously closes...
Bob Gailer
bgailer at alum.rpi.edu
Sun Nov 26 07:42:07 CET 2006
Alan Gilfoy wrote:
> Hello All.
> I've been concocting some simple programs based on an online tutorial,
> and I, of course, save a program as a .py file.
>
> When running my program via IDLE, once I've cleaned out the bugs, it
> works as I expect it to.
>
> But I noticed something else:
>
> Clicking directly on the file's icon has the program open in the
> Windows command line program as a .exe file.
>
> The command line program seems to work through my program OK, but the
> command line program shuts down immediately after the program has run
> through, as opposed to staying open in order to display the result.
This is true of any executable on almost any system. If there is no
deliberate pause-before-terminating, then the program will terminate and
the window will close. This has been asked so many times on these lists
I am almost weary of reading & responding.
Putting raw_input() at the end is not a workaround. It is the solution.
Unless you want to redesign the operating system.
[I
> noticed that if the command line program is not waiting for a resposne
> to a prompt, it stays open.]
>
> Relevant code block:
>
> #rectangle stuff
> length = int(raw_input("Please enter the length of your rectangle, as
> a whole number : ")) #lets user input a number
> width = int(raw_input("Please enter the width of your rectangle, as a
> whole number : ")) #lets user input a number
> area = length * width
> print " "
> print " "
> print " "
> print "the length is"
> print length
> print " "
> print "the width is"
> print width
> print " "
> print "So the area is"
> print area
> print " "
>
> end = (raw_input("Type something, and press Enter, and the program
> should shut down."))
> #workaround
>
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
Bob Gailer
510-978-4454
More information about the Tutor
mailing list