Timeout for python inputs
Project description
timedinput
A Python module that waits for a specified amount of time for user input. If no input is received within the given timeout period, the module sets the variable value as per the default or raises an exception. This module is similar to the inputtimeout module, but with a few differences.
Usage
The timedinput function takes three optional arguments: prompt, timeout, and default.
from timedinput import timedinput
# Prompt the user for input with a timeout of 10 seconds
user_input = timedinput("Enter something: ", timeout=10)
# Prompt the user for input with a timeout of 5 seconds and a default value of "default"
user_input = timedinput("Enter something: ", timeout=5, default="default")
If the user enters input within the specified timeout, the function returns the user's input as a string. If the user does not enter input within the specified timeout, the function returns the default value (if one was provided) or raises a TimeoutOccurred exception.
Installation
The timedinput
module can be installed using pip.
pip install timedinput
Compatibility
Works on all platforms, including Windows and Unix-like operating systems.
License
Released under the MIT License. See the LICENSE file for more information.
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
Built Distribution
File details
Details for the file timedinput-0.1.1.tar.gz
.
File metadata
- Download URL: timedinput-0.1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86ab8f178163ea98e066480e39b36acd933fa6a94509a46274edeb7671327c35 |
|
MD5 | 55c4eba6bab81f1d2756d79ed3fcd74f |
|
BLAKE2b-256 | 831d2b712b126632762ae74954d0d842d0d43d8fd8b38de4c70f451f709b1b2a |
File details
Details for the file timedinput-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: timedinput-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 987fdbdda1a1b40784495cb6ed2eccd334d5c78ca70104861deecd226549681f |
|
MD5 | bbd7e22b2a120d2f7a53ea0bcc76f24b |
|
BLAKE2b-256 | aee8fabcb79d89ae44d1f37890895077f9ab33f22256228a01606337700f37b9 |