[Tutor] more about how I overcame not being able to run my programs

2012-03-15 Thread Tamar Osher

I am very appreciative for the many valuable individuals who graciously take 
their precious time to help others in need.  Special thanks to:
Brian van den Broek,Bob Gailer,and Hugo Arts.
I followed all the instructions of Hugo, Bob, and Brian.  This is specifically 
what I am now doing so that I can see the programs that I run, and also be able 
to provide user input:
try:import os# my programfinally:input ('\n\t\t\tPress the enter 
key to continue.')os.system ('pause') 



  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] more about how I overcame not being able to run my programs

2012-03-15 Thread Alan Gauld

On 15/03/12 22:39, Tamar Osher wrote:


try:
import os
# my program
finally:
input ('\n\t\t\tPress the enter key to continue.')
os.system ('pause')


It's more conventional to put the import at the very top, before the 
try: line.


But otherwise what you have should be fine. There are other ways of 
doing it and eventually you may write programs that don't require the 
press enter... line and you can then miss out all of the code above. But 
for learning that's fine.


Or just run your programs inside IDLE or, as someone else suggested, 
Eclipse and PyDev (although personally that seems like overkill!)


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] more about how I overcame not being able to run my programs

2012-03-15 Thread Steven D'Aprano

Alan Gauld wrote:

On 15/03/12 22:39, Tamar Osher wrote:


try:
import os
# my program
finally:
input ('\n\t\t\tPress the enter key to continue.')
os.system ('pause')


It's more conventional to put the import at the very top, before the 
try: line.


True, but in this case, if there is an import error, the message will flash by 
without being read. Wrapping the *entire* program, imports and all, ensures 
that the program will pause regardless of what happens.



--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor