473,785 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Alternative to raw_input ?

I need something like "Press any key to continue" code for my program.
Currently I use : raw_input("Pres s Enter to continue ") but it's lame.
Jul 18 '05 #1
16 5647
On Fri, 11 Feb 2005 17:26:04 +0100, BOOGIEMAN <BO*********@ya hoo.com> wrote:
I need something like "Press any key to continue" code for my program.
Currently I use : raw_input("Pres s Enter to continue ") but it's lame.


Err, why?

--
Cheers,
Simon B,
si***@brunningo nline.net,
http://www.brunningonline.net/simon/blog/
Jul 18 '05 #2
On Fri, 11 Feb 2005 16:35:19 +0000, Simon Brunning wrote:
Err, why?


It looks to ugly this way. I want to press
any key without ENTER to continue
Jul 18 '05 #3
On 2005-02-11, BOOGIEMAN <BO*********@YA HOO.COM> wrote:
On Fri, 11 Feb 2005 16:35:19 +0000, Simon Brunning wrote:
Err, why?


It looks to ugly this way. I want to press
any key without ENTER to continue


Like somebody already said: use the WConio module.

Somebody already posted a link.

I suggest you go look at it.

--
Grant Edwards grante Yow! ... the MYSTERIANS
at are in here with my
visi.com CORDUROY SOAP DISH!!
Jul 18 '05 #4
den
BOOGIEMAN wrote:
On Fri, 11 Feb 2005 16:35:19 +0000, Simon Brunning wrote:

Err, why?

It looks to ugly this way. I want to press
any key without ENTER to continue


Did you try this:

import msvcrt
msvcrt.getch()
Jul 18 '05 #5
On Fri, Feb 11, 2005 at 05:37:19PM +0100, BOOGIEMAN wrote:
On Fri, 11 Feb 2005 16:35:19 +0000, Simon Brunning wrote:
Err, why?


It looks to ugly this way. I want to press
any key without ENTER to continue


read the documentation on readline.

Hmm! it says "Availabili ty: Unix". Any particular reason? readline
should be fine on OSX and Win32

--
John Lenton (jo**@grulic.or g.ar) -- Random fortune:
sugar daddy, n.:
A man who can afford to raise cain.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCDOLjgPq u395ykGsRAig6AJ 9extU/bMx7GbBs1DGrWKk fAx8bhACgiE5w
jhda3sNi9vgHa7+ x2vau4Z8=
=qbJW
-----END PGP SIGNATURE-----

Jul 18 '05 #6
Err, why?

It looks to ugly this way. I want to press
any key without ENTER to continue


How about modifying it to

raw_input("Pres s ENTER to continue ")

Skip
Jul 18 '05 #7
On Fri, 11 Feb 2005 18:00:08 +0100, den wrote:
Did you try this:

import msvcrt
msvcrt.getch()


Yes, that's what I need. Thank you.
BTW, sometimes program continues
without me pressing any button, why ?
Jul 18 '05 #8
BOOGIEMAN wrote:
On Fri, 11 Feb 2005 18:00:08 +0100, den wrote:

Did you try this:

import msvcrt
msvcrt.getch( )

Yes, that's what I need. Thank you.
BTW, sometimes program continues
without me pressing any button, why ?


Probably because you had already hit a key earlier, and
it was still in the keyboard queue.

You can flush it first:

print prompt
while msvcrt.kbhit():
msvcrt.getch()
msvcrt.getch()

Pack that up in a subroutine and call it when
you need to pause and continue only when the user
has seen your prompt. Any previous keystrokes
will be discarded by the loop, then it will wait
for a new one to be hit.
-Peter
Jul 18 '05 #9
Skip Montanaro wrote:
How about modifying it to

raw_input("Pres s ENTER to continue ")


You want him to just capitalize ENTER in the current message?
--
Michael Hoffman
Jul 18 '05 #10

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

Similar topics

1
2521
by: Hugh | last post by:
I am using python 2.3 through the PythonWin program on windows. I would like to create a console-based interactive session. The program raw_input is almost exactly what I'd like, except that whenever I call raw_input(), it pops up a window on my screen. I'd much rather have it read from the interactive window. Is there something out there, as easy as raw_input(), that I can use? Thanks for any clues!
5
3001
by: Helmut Jarausch | last post by:
Hi when using an interactive Python script, I'd like the prompt given by raw_input to go to stderr since stdout is redirected to a file. How can I change this (and suggest making this the default behaviour) Many thanks for a hint, Helmut Jarausch
2
7241
by: J. W. McCall | last post by:
I'm working on a MUD server and I have a thread that gets keyboard input so that you can enter commands from the command line while it's in its main server loop. Everything works fine except that if a player enters the 'shutdown' command, everything shuts down, but the input thread is still sitting waiting for enter to be pressed for raw_input. After enter is pressed, it exits back to the command prompt as it should. I'm wondering if...
0
1821
by: dale | last post by:
Python newbie disclaimer on I am running an app with Tkinter screen in one thread and command-line input in another thread using raw_input(). First question - is this legal, should it run without issue? If not can you point me to a description of why. While updating objects on the screen I get a segfault after an indeterminate number of updates. It doesn't seem to matter how quickly the updates occur, but it does segfault faster...
1
2951
by: JerryKreps | last post by:
Hi, folks -- I'm a Python pup. As you can see from the session copied at the end of this post, I have the latest version of Python, and I've been using the Editor-Shell of the latest version of Boa Constructor while going through some Python tutorials. Everything was working as expected until I started using the raw_input built-in function. There seems to be some unreliable behavior in Boa Constructor's Editor - Shell. If you look...
21
8778
by: planetthoughtful | last post by:
Hi All, As always, my posts come with a 'Warning: Newbie lies ahead!' disclaimer... I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? I would like to include the ability to edit an existing value (drawn from an SQLite table) using a DOS console Python app, but my gut
17
4202
by: Stuart McGraw | last post by:
In the announcement for Python-2.3 http://groups.google.com/group/comp.lang.python/msg/287e94d9fe25388d?hl=en it says "raw_input(): can now return Unicode objects". But I didn't see anything about this in Andrew Kuchling's "2.3 What's New", nor does the current python docs for raw_input() say anything about this. A test on a MS Windows system with a cp932 (japanese) default locale shows the object returned by raw_input() is a str()...
7
2048
by: Mike Kent | last post by:
It's often useful for debugging to print something to stderr, and to route the error output to a file using '2>filename' on the command line. However, when I try that with a python script, all prompt output from raw_input goes to stderr. Consider the following test program: === Start test.py === import sys
8
5321
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples. (Sorry, long email) The first two examples are behaving normal, the thirth is strange....... I wrote the following flabbergasting code: #-------------------------------------------------------------
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8972
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
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
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.