473,583 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: How can I handle the char immediately after its input, withoutwaiting an endline?

rishi pathak wrote:
The below piece of code should give you some understanding

import tty
import sys
tty.setraw(sys. stdin.fileno())
char=''
print "Press x to exit"
while char != 'x' :
char = sys.stdin.read( 1)
print "You entered : ",char
# Your code here
Does not work on Windows, at least with 3.0, as tty fails trying to
import termios. There, use msvcrt module
"msvcrt.kbh it()
Return true if a keypress is waiting to be read.
msvcrt.getch()
Read a keypress and return the resulting character. Nothing is echoed to
the console. This call will block if a keypress is not already
available, but will not wait for Enter to be pressed. If the pressed key
was a special function key, this will return '\000' or '\xe0'; the next
call will return the keycode. The Control-C keypress cannot be read with
this function.
"
>

On Wed, Oct 22, 2008 at 2:34 PM, Lave <la*********@gm ail.com
<mailto:la***** ****@gmail.com> wrote:

Hi, all.

I'm a new comer. So This question maybe sutpid.:)

I want to write something that handle every char immediately after its
input. Then tehe user don't need to type [RETURN] each time. How can I
do this?

Thanks in advance.
--
Regards

Lave
--
http://mail.python.org/mailman/listinfo/python-list


--
Regards--
Rishi Pathak
Pune-Maharastra
------------------------------------------------------------------------

--
http://mail.python.org/mailman/listinfo/python-list
Oct 22 '08 #1
0 925

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

Similar topics

4
5418
by: jagmeena | last post by:
Hello, I am sure this problem has been addressed before, however, I could'nt get a suitable solution to my problem. Hence I am posting here. Thanks a lot for all your help. The code I have is typedef struct Rec { unsigned char msg; unsigned long len;
3
2867
by: Yusuke Urameshi | last post by:
How can I "save" a char? Egg: I write a program that asks the name of the user. Then I want to keep this name saved so the program can use it later. BUT I can't save more than one char, so if the program asks the name of the user and saves it, I can't save any other word to use later, or I will lost the name.... this seems confusing, but...
27
4614
by: gmtonyhoyt | last post by:
I need assistance coming up with a clean way to handle filename extensions with my application. While I can come up with several ways of doing so on my own, I felt perhaps it would be worth asking here to see what more effective or accepted methods for doing would be presented. The issue is this. My application accepts files names,...
6
2852
by: Leandro Berti via DotNetMonster.com | last post by:
Hi All, I wrote a code to do serial communication with an equipament. When i use the code outside of threaded class it seens work properly, but when i put inside a class and execute a thread in the first seconds the communication is ok, later i receive read/write error. I?ve been in MSDN site and there i discover that the read/write error...
6
5672
by: Mark | last post by:
Hello, I'm trying to handle HttpRequestValidationException. If a hacker enters certain values into a textbox, like "<script>", it will trigger this error. I understand why .Net has this, but I need a way to gracefully handle it. Ideally the app would catch it as invalid input, and then return control to the user instead of throwing an...
6
2040
by: Liming | last post by:
Hi, In a typical 3 tier model (view layer, busines layer and data access layer) where do you handle your exceptions? do you let it buble up all the way to the .aspx pages or do you handle it in your business layer and/or data access layer? suppose in my data access layer, I provide try and catch, log the exception and re-throw it back...
0
1581
by: wmihelpme | last post by:
Hi All, I have written a WMI Program which changes the network settings like ip address, subnet mask, gateway and dns addresses for given adapter number. when I call that function for adapter number-1, its executing perfectly. when I immediately make the call to that function with adapter number-2, its giving me the segmentation error and...
0
729
by: Lave | last post by:
Hi, all. I'm a new comer. So This question maybe sutpid.:) I want to write something that handle every char immediately after its input. Then tehe user don't need to type each time. How can I do this? Thanks in advance.
7
175
by: Lie Ryan | last post by:
>>I want to write something that handle every char immediately after its Don't you think that getting a one-character from console is something that many people do very often? Do you think that all these platform independent code should be moved to the interpreter level instead (and raises the appropriate error when the platform somehow...
0
8328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7936
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
6581
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...
1
5701
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...
0
5375
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
3820
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...
1
2334
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
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1158
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...

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.