I am trying to figure out how to create a little Python script that can take the following parameters:
- prompt – string
- time to wait as an integer
- number of characters before stopping
The last one is the number of characters I can enter before the program stops accepting characters and starts processing the input. I’ve seen some people use Python’s select.select method, but that doesn’t account for the 3rd item. I’m leaning towards curses, although I don’t know if it supports a timeout which is making me think of threads. Any insights would be great! This will run on Linux with Python 2.6.
Ok, I have achieved it :D.
It’s fairly incomplete; I just put a few values to test it. A few words of explanation:
cursesfor that,end_time), and then passend_time - current_timein seconds as timeout toselect(),