Re: [Tutor] seeing the results of a python program in windows7
On 15 Mar 2012 04:14, "bob gailer" wrote: > > On 3/14/2012 12:12 PM, Tamar Osher wrote: >> I can run a python program in Notepad++, but what happens is that the black box flashes and disappears immediately, so that I never see the results. >> >> How can I style it so that the results of the program stay on the computer screen, for me to see? > > Do this: > > try: > # your program goes here > finally: > raw_input("Press any key") > # if you are running Python 3 replace raw_input with input > > Adding the try-finally construct ensures that any exception in your code will be visible. > Alternatively, invoke python to run your program at the prompt with the interactive switch: python -i myscript.py Best, Brian vdB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] seeing the results of a python program in windows7
On 3/14/2012 12:12 PM, Tamar Osher wrote: Hi. I ask for help. Thanks very much for your time. I can run a python program in Notepad++, but what happens is that the black box flashes and disappears immediately, so that I never see the results. If you expected anything else you don't understand how windows runs programs. How can I style it so that the results of the program stay on the computer screen, for me to see? Do this: try: # your program goes here finally: raw_input("Press any key") # if you are running Python 3 replace raw_input with input Adding the try-finally construct ensures that any exception in your code will be visible. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] seeing the results of a python program in windows7
On 14/03/2012 16:12, Tamar Osher wrote: Hi. I ask for help. Thanks very much for your time. I can run a python program in Notepad++, but what happens is that the black box flashes and disappears immediately, so that I never see the results. How can I style it so that the results of the program stay on the computer screen, for me to see? Using IDLE, the Python Shell, I can click File/New Window, to get a new window that allows me to RUN a program. But the RUN option does not allow me to choose which program I want to run. How can I style it so that I can choose which program to run, and how can I see the results of that program? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor Now that you can actually run a program, would you please be kind enough to tell everybody for the record how you overcame the problem "I cannot run Python programs" as asked in the thread entitled "Cannot run python programs on my windows7 computer". -- Cheers. Mark Lawrence. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] seeing the results of a python program in windows7
On Wed, Mar 14, 2012 at 5:12 PM, Tamar Osher wrote: > Hi. I ask for help. Thanks very much for your time. > > I can run a python program in Notepad++, but what happens is that the black > box flashes and disappears immediately, so that I never see the results. > How can I style it so that the results of the program stay on the computer > screen, for me to see? > The black box disappears when the program exits. To stop your program from exiting immediately, you can wait for user input at the end of your program. In python 3, this is the input() function. In python 2 you should use raw_input(). Alternatively, you could add the lines import os os.system("pause") at the end of the program, which asks you to press any key and then exits. > Using IDLE, the Python Shell, I can click File/New Window, to get a new > window that allows me to RUN a program. But the RUN option does not allow > me to choose which program I want to run. How can I style it so that I can > choose which program to run, and how can I see the results of that program? > If you want to use IDLE it's possible as well, and you don't need to change your program for it. Just open the file you want to run in IDLE (in the IDLE menu click File -> Open, or right click the file in explorer and choose "Edit with IDLE") Then, either press F5 or click Run -> Run Module. HTH, Hugo ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] seeing the results of a python program in windows7
Hi. I ask for help. Thanks very much for your time. I can run a python program in Notepad++, but what happens is that the black box flashes and disappears immediately, so that I never see the results. How can I style it so that the results of the program stay on the computer screen, for me to see? Using IDLE, the Python Shell, I can click File/New Window, to get a new window that allows me to RUN a program. But the RUN option does not allow me to choose which program I want to run. How can I style it so that I can choose which program to run, and how can I see the results of that program? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Cannot run python programs on my windows7 computer
On 14 Mar 2012 02:56, "Tamar Osher" wrote: > > Hello. Is there someone who can tutor me about how to "run" Python files on my windows7 computer? I have IDLE (the white box, the Python shell). I have the command prompt (the black box). And I also have Notepad++ on my computer. I have a total of 3 ways of trying to run my Python programs. I have tried and tried. The books Hi Tamar, I remember that I found it a bit non-obvious to get this working when I started with python, too. Unfortunately, that is nearing a decade ago and I don't recall what the bump was. If you can get idle going, you can run programs. On the File menu, New opens a new editor window where you can type a program and Open opens an extant file. It also provide a different menu with Run. If that doesn't run your program, something is messed up with your install. Idle isn't always the best choice; you'll want to be able to run from a command shell (the "black box"), too. What happens when you type 'python' there? If you get a python prompt, save a file mytest.py that has the sole line raw_input(42) somewhere and try 'python full\path\to\mytest.py'. If you don't get a python prompt on typing 'python' type 'path' and report your result. I don't have a windows box, so I am going on memory and might have got things wrong. As for top posting: notice how my text follows yours? This means a reader of this email hits the context before my content. If you are on a number of lists and watching a number of threads, top posted emails are annoying as you have to scroll down to read the context then up to read the content. Whether that makes sense to you or not, the community from which you seek help strongly prefers you not top post, so don't. Best, Brian vdB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor