Implemenation of thread-based timed input object
Project description
TimedInputPy
TimedInputPy is a python library that provides input function/object that has a thread based time limit on input.
API
object | method | description |
---|---|---|
TimedInput(timeout, prompt, default | Timed input reader: | |
timeout -> how long to wait? | ||
prompt -> what to ask? | ||
default -> what to sat when timeout happens? | ||
action -> action callback to perform when timeout happens | ||
get_input() | Function to be used as input reader | |
read() | Reads the input from the reader | |
timed_input(timeout, prompt, default) | Function for reading timed input, arguments same as above |
Example usage
# Sample usage:
if __name__ == '__main__':
test_timeout = 5
test_prompt = 'Enter name: '
test_default = 'world'
# As a method
s = timed_input(test_timeout, test_prompt, test_default)
print('Hello {}!'.format(s), flush=True)
print()
# As a class
s = TimedInput(test_timeout, test_prompt, test_default).read()
print('Hello {}!'.format(s), flush=True)
Instalation
Module can be installed using pip3:
pip3 install TimedInputPy
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
timedinputpy-1.0.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for TimedInputPy-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d91bf0986b9e80de47c1eb95d5da031f23b293d8311d6ad4c7aca54bfbc3a37 |
|
MD5 | e1c43501e40f3d61f255c47364abbfe7 |
|
BLAKE2b-256 | f7c8b775de5bf4a9fb46858ce527137cc9b6724ce5e2d7268e6ceeb7fb2537ba |