EzInputs
EzInputs is built to get rid of the need to put while loops and try/except blocks around your type cast input() calls
The old way
while True:
num = input("Enter a number: ")
try:
num = int(num)
break
except ValueError:
print("Invalid integer, try again")
The EzInputs way
import ezinputs
num = ezinputs.int_input()
Depending on how you measure it, ezinputs is about 10 times better!
Docs & Useage
Before we begin, these functions are all in the ezinputs.py file that ships in this package. Therein, full documentation is given for each function.
Primitive types
In this section we will look at the 4 primitive input types ezinputs has to offer.
All basic input types have two optional arguments;
prompt - the input prompt shown to the user (function-specific default)
error - the message displayed when an invalid value is entered (function-specific default)
Integer input
>>> ezinputs.int_input()
Enter an integer: 5
(returns)
5
Float input
>>> ezinputs.float_input()
Enter a float: 12.23
(returns)
12.23
Boolean input
>>> ezinputs.bool_input()
Enter boolean: True
(returns)
True
String input
Please just use the builtin python input(), this str_input() function is extremely redundant!
>>> ezinputs.str_input()
Enter a string: hello world!
(returns)
'hello world!'
Collection types
In this section we will look at the 4 collection input types ezinputs has to offer
The collection inputs have additional optional arguments on top of the besic input arguments;
astype - the datatype required for values (defaults to str)
count - the number of items to retrieve (defaults to 1)
List input
>>> ezinputs.list_input(count=2, astype=int)
Enter item 1: 5
Enter item 2: 12
(returns)
[5, 12]
Set input
>>> ezinputs.set_input(count=3, astype=float)
Enter item 1: 7.6
Enter item 2: 2
Enter item 3: 4
(returns)
{2.0, 4.0, 7.6}
Tuple input
>>> ezinputs.tuple_input(count=3, astype=bool)
Enter item 1: a
Enter item 2: 1
Enter item 3: True
(returns)
(True, True, True)
Dictionary input
>>> ezinputs.dict_input(count=3)
Enter key 1: sugar
Enter str value for sugar: 150g
Enter key 2: flour
Enter str value for flour: 400g
Enter key 3: insert_cake_ingredient_here
Enter str value for insert_cake_ingredient_here: some
(returns)
{'sugar': '150g', 'flour': '400g', 'insert_cake_ingredient_here': 'some'}
Author
Will Johnson
Discord: __wcj__#3111
Email: 277willjohnson@gmail.com
Website: https://heyteach.co.uk/
Metadata
Release files for ezinputs 1.0.1
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 | Actions |
|---|---|---|---|---|
| ezinputs-1.0.1.tar.gz | 4.6 kB | Without provenance | Details for ezinputs-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ezinputs-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for ezinputs-1.0.1-py3-none-any.whl |
Total release size: 10.2 kB
Release files / ezinputs-1.0.1.tar.gz
| Download URL | ezinputs-1.0.1.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e1dbf978b7cc8f58fbf043b74ceb7ece77d403a28362301c3f47e4dcd733f86
|
|
BLAKE2b-256 checksum How to use checksums |
2630dc139eb57c3e707b63660eb85f44b0f400b72c243958bf6a3ad224701a57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Release files / ezinputs-1.0.1-py3-none-any.whl
| Download URL | ezinputs-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6710e4842aeea0af1312f584eef7ee290203c87078de2a4cdc9241b207d56e51
|
|
BLAKE2b-256 checksum How to use checksums |
086a68c51bc5d3c471a0e3ce6681317ab13754de2617e93625ed90214ad7bcfb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Security for ezinputs 1.0.1
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.