468,287 Members | 1,905 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,287 developers. It's quick & easy.

how can I run python interactively?

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
5 1760
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
"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
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
Thanks guys for the reply.
This is very helpful

Nov 3 '05 #5
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.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
699 posts views Thread by mike420 | last post: by
3 posts views Thread by Emile van Sebille | last post: by
50 posts views Thread by Edward K. Ream | last post: by
38 posts views Thread by kbass | last post: by
reply views Thread by Simon Eves | last post: by
1 post views Thread by anonymous | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.