koinput
Maximal simplification of Input / Output for text programs.
What’s new?
- 0.3.2
Minor improvements and bug fixes.
Fixed inaccuracies in README file.
- 0.3.1
Added multiple input for int_input and float_input.
- 0.3.0
Added a new ProgressBar function. How to use see below.
Added input_suggestion_style for Menu and Inputs.
Installation
Requirements colorama library.
pip install koinput
How to use
Inputs
The library has two types of inputs:
int_input
float_input
They have the same settings and differ only in the type of output.
Explanation of input parameters
def int_input(input_suggestion: str = '', greater: float or int = float('-inf'), less: float or int = float('inf'),
console_style: str = Fore.RESET, error_message: str = 'Invalid number format.\n',
error_message_style: str = Fore.RED, multiple_numbers_in_line: bool = False,
input_is_greater_than_less_error: str = "The number is greater than acceptable.\n",
input_is_less_than_greater_error: str = "The number is less than acceptable.\n",
input_is_less_error_style: str = None, input_is_greater_error_style: str = None,
strictly_greater: bool = True, strictly_less: bool = True,
input_suggestion_style: str = None) -> int or list:
- input_suggestion=""
Input suggestion that will be displayed when the function is run.
- greater=float('-inf'), less=float('inf')
The range in which the entered number should be included.
- strictly_greater=True, strictly_less=True
Controlling the mathematical strictly of comparisons.
- console_style=colorama.Fore.RESET
Sets the base display style for the terminal. I recommend using the colorama library for easier style customization. You can also use standard sequences (example: “x1b[39m”).
- error_message='Invalid number format.\n'
Error message when converting input to number.
- error_message_style=colorama.Fore.RED
Error message style.
- input_is_greater_than_less_error="The number is greater than acceptable.\n"
The message issued when the number is greater than allowed.
- input_is_less_than_greater_error="The number is less than acceptable.\n"
The message issued when the number is less than allowed.
- input_is_less_error_style=None, input_is_greater_error_style=None
Out of range error styles.
- input_suggestion_style=None
Input suggestion style.
- multiple_numbers_in_line=False
If True the function will return a list of numbers entered in one line.
Usage example
def area_triangle(base, height):
return 0.5 * base * height
print(area_triangle(float_input(input_suggestion='Enter the base of the triangle: '),
float_input(input_suggestion='Введите высоту треугольника: ')))
mas = [randint(0, 999) for i in range(int_input(input_suggestion="Enter the size of the array: "))]
ProgressBar
The progress bar is designed to show the progress of long-running tasks.
First, we import the ProgressBar class.
from koinput import ProgressBar
The class has properties:
- ProgressBar.max_value: int or float = 100
The maximum value from which the percentage is calculated or indicated in the counter mode.
- ProgressBar.counter: bool = False
Enables counter mode. It displays not percentages, but value from max_value.
- ProgressBar.string: str = "[########################################] @@@%"
Indicates the view of the Progress Bar.
- ProgressBar.progressbar_symbol: str = "#"
A symbol indicating the placement of a progress bar.
- ProgressBar.percent_symbol: str = "@"
The symbol indicating the placement of percent (as well as the number of decimal places) or in counter mode only indicates its location.
- ProgressBar.counter_separator: str = '/'
A character or string to be displayed between value and max_value in counter mode.
To display the progress bar, use the show function.
ProgressBar.show(value: int or float, text: str = None)
- value
The current value of the progress bar.
- text=None
Comment for the current operation.
Usage example
from koinput import ProgressBar
from time import sleep
ProgressBar.max_value = 123
for i in range(124):
ProgressBar.show(i)
sleep(0.07)
ProgressBar.max_value = 10
ProgressBar.counter = True
ProgressBar.string = "|&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&| {*}"
ProgressBar.progressbar_symbol = "&"
ProgressBar.percent_symbol = "*"
ProgressBar.counter_separator = ' element of '
for i in range(11):
ProgressBar.show(i, f"Element {i}")
sleep(0.7)
Metadata
Release files for koinput 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| koinput-0.3.2.tar.gz | 11.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| koinput-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.3 kB
Release files / koinput-0.3.2.tar.gz
| Download URL | koinput-0.3.2.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7791a95894faf38dbb5128163700f3e286b830522254ac038a371d590bf88f1
|
|
BLAKE2b-256 checksum How to use checksums |
0b3e222cf4250e7afb6d37886493a3cbe5bee3263d215dc2fe70ad0cc595ec8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.8.5 Linux/5.4.0-1040-azure
|
Release files / koinput-0.3.2-py3-none-any.whl
| Download URL | koinput-0.3.2-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
850fb33f1970867629957b3f4b9a3bae0c2be2149d593793d4a7c473b2ceb26a
|
|
BLAKE2b-256 checksum How to use checksums |
beddd84687c924909edd1615a8098a6a13116e3166d6271f68b784b837c2b969
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.8.5 Linux/5.4.0-1040-azure
|
Security for koinput 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.