[Tutor] How to only give the user so much time to enter response?

james carnell jimcarnell at yahoo.com
Sun Mar 15 09:22:00 CET 2009


Trying to use Timer in console based game that gives the user so much time to act. If they do not act then it just passes the turn back to the program to do the next thing. I have Python 2.5 and Windows XP.

http://www.python.org/doc/2.5.2/lib/timer-objects.html
def hello():
    print "hello, world"

t = Timer(30.0, hello)
TypeError:__init__() takes exactly 2 arguments (3 given)
===============================
http://mail.python.org/pipermail/tutor/2004-November/033333.html

Also tried this, but I think it might be outdated. When I type it 
in it never triggers the function.
================================
so... this kind is where I am:

t=Timer(10.0)

def waitFunction(timerObj):
   newMove = 5 #5 = player will stay in same position on 2d array
   newMove = int(raw_input("Move 1-9 / 0 to quit:"))
   timerObj.start()
   while timerObj.isAlive():
      pass
   print newMove

It works, but I am guessing it isn't a very good way to do it. 
I am curious why I can't get anything to work from the docs. 
Any help appreciated (and hopefully yahoo won't butcher my indentation).
   











      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090315/884cdcb2/attachment.htm>


More information about the Tutor mailing list