473,578 Members | 3,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1924
try something like ->

s = raw_input("Plea se 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.readl ine()

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("plea se 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("Plea se Hit a Key...")

s being the string they typed before hitting enter.

or you could use

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

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.pytho n:

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.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
=============== =============== =============== =============== == <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.ne tcom.com/> <

Nov 3 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
18930
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it...
699
33646
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it...
3
1477
by: Emile van Sebille | last post by:
QOTW: "...I want to reserve .var for the "with" statement (a la VB)." --Guido van Rossum "...at some point in the future Python *will* grow (optional) type declarations for all sorts of things (arguments, local variables, instanc e variables)." --Guido van Rossum The developer list responds to a request for Master Thesis ideas with a
50
5465
by: Edward K. Ream | last post by:
I would like to say a few (actually more than a few) words here about some recent discoveries I have made concerning the interaction of Leo and Python. If you don't want to hear an inventor enthuse about his work, please feel free not to read further :-) There are at least three, no four, no five, no six, no seven reasons why Leo and Python...
38
3712
by: kbass | last post by:
In different articles that I have read, persons have constantly eluded to the productivity gains of Python. One person stated that Python's productivity gain was 5 to 10 times over Java in some in some cases. The strange thing that I have noticed is that there were no examples of this productivity gain (i.e., projects, programs, etc.,...). ...
0
1326
by: Cameron Laird | last post by:
QOTW: "Really, of course, the only things you need to make explicit are the ones that readers don't understand." -- Steve Holden "Working with unicode objects in Python is so transparent, it's easy to forget about what a C extension would likely want." -- Kevin Dangoor "You take leadership in a small area, and you keep it as long as you...
5
4614
by: Russ | last post by:
I wrote a simple little function for exiting with an error message: def error ( message ): print_stack(); exit ("\nERROR: " + message + "\n") It works fine for executing as a script, but when I run it interactively in the python interpreter it kills the interpreter. That's not what I want. Is there a simple way to have a script terminate...
0
1197
by: Simon Eves | last post by:
I am trying to write a Python module to embed the functionality of Maya (the 3D modelling and animation application from Autodesk, formerly Alias) for doing scripted scene manipulation and rendering processes in Python. I am aware of the CGKit project, which does this and a lot more, but it is over-complex for our needs, and also does not...
1
5764
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for example: answer_str = raw_input(' Enter answer ') Herr Üü
0
8125
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7874
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8148
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6522
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5342
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3781
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3798
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1389
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.