LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2008, 11:58 AM   #1
deathalele
Member
 
Registered: May 2008
Location: deep dark north wales
Distribution: Zenwalk
Posts: 162

Rep: Reputation: 30
is it possible to override the raw_input() command in python


i'm making a space invaders type game where objects fall from the sky and the user aims their gun by pressing 1, 2 or 3.
for this game to work properly i would need a way of overriding the raw_input() function so that if the player hasn't entered anything after x seconds then it takes it as ''.

thanks a lot
iwan
 
Old 10-05-2008, 04:26 PM   #2
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
cross platform

Using raw_input would not be appropriate in this case. You could (on UNIX) use signals and alarms in conjunction with raw_input in a simple case, but not recommended. First, do you need this to work cross platform? If so, you will find yourself having to develop some platform-dependent code. There is no magic bullet as of yet for handling terminals uniformly across platforms.

This post shows one UNIX way of handling the problem. Even though the aim in this post was different, it is entirely relevant.

This recipe, although somewhat dated, will give you an idea and starting point for what you will need.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
If no raw_input: (Python question) xadrith Programming 4 07-26-2008 07:21 AM
Suspending operations with raw_input (Python) xadrith Programming 1 07-24-2008 05:09 PM
python - getting command result Hewson Programming 1 08-01-2007 06:22 PM
Can the 'dd' command override disc protection? Hitboxx Linux - General 4 07-09-2007 09:38 PM
Python: raw_input & puTTy on remote server Hairein Programming 1 01-01-2007 08:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration