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.1.tar.gz
(2.6 kB
view details)
Built Distribution
File details
Details for the file timedinputpy-1.0.1.tar.gz
.
File metadata
- Download URL: timedinputpy-1.0.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 256769165fdedddc3e7001207aa924c105c732c94c6ac0dd87bf12372084c80b |
|
MD5 | d30e136b26d4729296dce5ec271b5b59 |
|
BLAKE2b-256 | e46e8829b38c63e2ce80984c0d3ebd6bc08ebd780bcaa4de90f7ca24faa1368b |
File details
Details for the file TimedInputPy-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: TimedInputPy-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 198fe4b3b2903ad083ce1106de0d9f3c438e94baf38e54b0be6b93f1f74bb0b2 |
|
MD5 | 1de3ffdd256b1bde6804a526cbb5c10b |
|
BLAKE2b-256 | 641e7099e1e051dfe8e375e0ee94df3a55e8cb80d3bcac1b35ab72d00a366530 |