By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,095 Members | 1,586 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,095 IT Pros & Developers. It's quick & easy.

how can I run python interactively?

P: n/a
I need to stop the program in the middle and pause there.

Are there anyway I can stop the program in the middle and have
something like:

please press y to continue.....

Thanks

Nov 3 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
try something like ->

s = raw_input("Please Press a button...")
#s is the string they type.

Although i believe i remember a PEP that said they were removing
raw_input so perhaps

print "Please Press A button..."
s = sys.stdin.readline()

would be better, note the above requires you to 'import sys'

Nov 3 '05 #2

P: n/a
"questions?" wrote:
I need to stop the program in the middle and pause there.

Are there anyway I can stop the program in the middle and have
something like:

please press y to continue.....


portable:

raw_input("please press return to continue.....")

to get a single character, you can use msvcrt.getch() on windows,
or the termios module on unix:

http://effbot.org/librarybook/msvcrt.htm
http://aspn.activestate.com/ASPN/Coo.../Recipe/134892
http://www.faqts.com/knowledge_base/...d/4490/fid/538
etc

</F>

Nov 3 '05 #3

P: n/a
You could use either:

s = raw_input("Please Hit a Key...")

s being the string they typed before hitting enter.

or you could use

print "Please hit a key..."
s = sys.stdin.readline()

the only reason i recommend the second is because i believe i saw in a
PEP that raw_input was being depreciated at some point, however i may
be wrong on that. (correction anyone?)

Nov 3 '05 #4

P: n/a
Thanks guys for the reply.
This is very helpful

Nov 3 '05 #5

P: n/a
On 2 Nov 2005 22:51:16 -0800, "Graham" <gr***********@gmail.com>
declaimed the following in comp.lang.python:

the only reason i recommend the second is because i believe i saw in a
PEP that raw_input was being depreciated at some point, however i may
be wrong on that. (correction anyone?)
If anything, I'd expect "input" to be the statement getting the
axe... After all, it's long been recommended to use raw_input instead of
input, and /then/ evaluate the data as needed.
-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Nov 3 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.