Simple, Safe User Input for Python
Project description
AskRow — Simple, Safe User Input for Python
AskRow is a beginner-friendly Python library that makes handling user input easy, clean, and reliable. It replaces Python's built-in input() with a smarter, more structured approach that automatically validates data, handles errors, and ensures users provide the correct input without writing repetitive code.
Installation
pip install askrow-py
Features
- Type-safe input - Get integers, floats, text, booleans with automatic type conversion
- Built-in validation - Validate ranges, length, patterns, and email formats
- Automatic retry - Re-prompts users when invalid input is entered
- Clear error messages - Friendly, human-readable error messages
- Simple API - Minimal, intuitive design for beginners
- Password input - Hidden password entry
- Choice menus - Select from a list of options
- Form builder - Collect multiple fields at once
- Confirm dialogs - Yes/No confirmation and value matching
- File picker - Validate file paths with extensions
Quick Start
from askrow_py import ask
age = ask.int("Enter your age: ", min_value=0, max_value=120)
name = ask.text("Enter your name: ", min_length=1, max_length=50)
email = ask.email("Enter your email: ")
is_student = ask.bool("Are you a student? (yes/no): ")
API Reference
ask.text(prompt, min_length, max_length, pattern, required)
Get text input with optional validation.
name = ask.text("Enter your name: ", min_length=2, max_length=50)
ask.int(prompt, min_value, max_value)
Get integer input with optional range validation.
age = ask.int("Enter your age: ", min_value=0, max_value=120)
score = ask.int("Enter your score: ", min_value=0, max_value=100)
ask.float(prompt, min_value, max_value)
Get float input with optional range validation.
price = ask.float("Enter price: ", min_value=0.0)
height = ask.float("Enter height (cm): ", min_value=0, max_value=300)
ask.bool(prompt, true_values, false_values)
Get boolean input with customizable true/false values.
is_active = ask.bool("Is active? (yes/no): ")
ask.email(prompt)
Get validated email address.
email = ask.email("Enter your email: ")
ask.password(prompt, min_length, max_length)
Get hidden password input.
password = ask.password("Enter password: ", min_length=8)
ask.choice(prompt, options, case_sensitive)
Select from a list of options.
color = ask.choice("Choose color: ", options=["red", "green", "blue"])
day = ask.choice("Choose day: ", options=["Monday", "Tuesday", "Wednesday"])
ask.confirm(prompt, default) or ask.confirm(prompt, match=value)
Get yes/no confirmation OR confirm if input matches a value.
# Yes/No confirmation
if ask.confirm("Delete file?", default=False):
print("File deleted")
# Password confirmation (match two inputs)
password = ask.password("Enter password: ", min_length=8)
confirm = ask.confirm("Confirm password: ", match=password)
ask.menu(prompt, options)
Display a numbered menu and get user selection.
choice = ask.menu("Select option:", ["Create Project", "Run App", "Exit"])
print(f"You chose: {choice}")
ask.file(prompt, exists, extensions, must_be_file, must_be_dir)
Get file path with validation.
file_path = ask.file("Select file:", exists=True, extensions=[".json", ".txt"])
ask.form(fields)
Collect multiple fields in a single form.
user = ask.form([
{"name": "name", "type": "text", "message": "Name:"},
{"name": "age", "type": "int", "message": "Age:"},
{"name": "email", "type": "email", "message": "Email:"},
{"name": "password", "type": "password", "message": "Password:"}
])
print(user) # {"name": "John", "age": 25, "email": "john@example.com", "password": "..."}
License
MIT License
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file askrow_py-1.0.0.tar.gz.
File metadata
- Download URL: askrow_py-1.0.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a048dc7c93d42a563fc9b8481719e87e561375638fab823d5449ead1cc9c298
|
|
| MD5 |
5bed0e8ef835444fce0346c5fa4f8ae2
|
|
| BLAKE2b-256 |
edbae47cb4226b51fcd32b51be302e2d0921a37370ba5bdb87f7ba31afbbfd85
|
File details
Details for the file askrow_py-1.0.0-py3-none-any.whl.
File metadata
- Download URL: askrow_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c254ea0618acecb585f8b711868b80ec3631247dfd75f76abc01f378d544589d
|
|
| MD5 |
cd504b2f1e3d2a1e7c5cc63cd10a58e7
|
|
| BLAKE2b-256 |
cf3562df251044bfc085c81a78781ab8c2d09e801c4c358283403cf13f0823a7
|