Is there a way one can interrupt the sleep() function with a key press in Python?
bumsfeld 413
Nearly a Posting Virtuoso
Recommended Answers
Jump to PostLook at KeyboardInterrupt in the Python reference. Right now, I don't have a good example. I try to work on one!
Jump to PostSo far I have only found one function that will work during the active sleep() ...
import time import msvcrt time.sleep(10) # prints the key value during sleep if msvcrt.kbhit(): print msvcrt.getch()
Edit:
Ouch! The IDE fooled me! This does not make sense, forget it! Sorry!
All 6 Replies
vegaseat 1,735
DaniWeb's Hypocrite Team Colleague
vegaseat 1,735
DaniWeb's Hypocrite Team Colleague
Ene Uran 638
Posting Virtuoso
a1eio 16
Junior Poster
vegaseat 1,735
DaniWeb's Hypocrite Team Colleague
a1eio 16
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.