bool_quetion
Python-module for asking yes/no or accept/cancel questions.
Installing
Install from PyP
pip install bool_quetion
Using a virtual environment.
Create virtual environment:
python3 -m venv .venv
Activate virtual environment:
source .venv/bin/activate
Install bool_quetion:
pip install bool_quetion
If you're not using a virtual environment and want to install packages globally, you'll likely need --break-system-packages to bypass restrictions that protect system:
pip install bool_quetion --break-system-packages
Install from APT repositories
As root or using sudo
Add APT repositories:
echo "deb https://pablinet.github.io/apt ./" > /etc/apt/sources.list.d/pablinet.list
Add APT Key:
wget -O /etc/apt/trusted.gpg.d/pablinet.gpg https://pablinet.github.io/apt/pablinet.gpg
Upload APT repositories:
apt update
Install bool_quetion:
apt install python3-bool-quetion
Using the code in Python 3.x
from bool_quetion import true_false
names = []
reply = True
while reply:
element = input ('Enter the full name: ')
names.append(element)
for name in names:
print (name)
reply = true_false('Do you wish to continue?', ['Yes or', 'no'])
else:
reply = True
It is also possible to customize the error message and highlight the characters that can be entered:
reply = true_false('Do you wish to continue?', ['Yes or', 'no'], True)
reply = true_false('Continue?', ['Yes or', 'no'], 'Error Key', True)
BONUS TRACK
Use this library in Bash.
#!/usr/bin/env python3
from sys import argv, exit
from bool_quetion import true_false
if 3 > len(argv) or len(argv) > 5:
print('Error in the number of arguments.')
exit(255)
arguments = argv[1:].copy()
arguments[1] = arguments[1].split('%')
err_number = 1
if len(arguments[1]) == 3 and arguments[1][2].isdecimal():
err_number = int(arguments[1][2])
arguments[1].pop()
if len(arguments) in (3, 4):
if arguments[-1].lower() in ('true', 'false'):
arguments[-1] = arguments[-1].lower() == 'true'
exit(0 if true_false(*arguments) else err_number)
Add execution permissions:
chmod +x true-false
Run the script:
./true-false 'Do you wish to continue?' 'Yes or%No'
./true-false 'Do you wish to continue?' 'Yes or%No' 'Bad key'
./true-false 'Do you wish to continue?' 'Yes or%No' 'Bad key' true
Run script with custom error code:
./true-false 'Do you wish to continue?' 'Yes or%No%5'
./true-false 'Do you wish to continue?' 'Yes or%No%5' 'Bad key'
./true-false 'Do you wish to continue?' 'Yes or%No%5' 'Bad key' true
Metadata
Release files for bool-quetion 0.1.8
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 | |
|---|---|---|---|---|
| bool_quetion-0.1.8.tar.gz | 15.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bool_quetion-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.5 kB
Release files / bool_quetion-0.1.8.tar.gz
| Download URL | bool_quetion-0.1.8.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a36a0ff5c1371a8ab988a256fb0cdb39b2479ac3d21a83679b17c16486b08449
|
|
BLAKE2b-256 checksum How to use checksums |
d64d4fc0d2602190cd366f43bae50960cd6f3d36dae6802191bc485f55a306de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Release files / bool_quetion-0.1.8-py3-none-any.whl
| Download URL | bool_quetion-0.1.8-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7766d6f70e7d07542b48f099c04eee11fcbe75cb6259495c3d47a9fcb4b0099f
|
|
BLAKE2b-256 checksum How to use checksums |
9d74a3361688c9eb47baa29591c3425635fdc474f04e08b6848701f9573de35f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Security for bool-quetion 0.1.8
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.