askput is a lightweight Python library for safe, validated, and interactive console input.
It removes repetitive input-validation logic and helps you build clean, readable CLI programs with minimal effort.
Python’s built-in input():
- always returns strings
- provides no validation
- leads to repeated
try / exceptblocks
askput offers a clean abstraction over these problems while staying simple and dependency-free.
- Integer and float input with bounds
- String length validation
- Email validation
- Secure password input
- Strong password rules
- Yes/No confirmations
- Phrase-based confirmation for dangerous actions
- Menu-based choice selection
- Regex (pattern) based input
- Multiple values input
- Fully tested with
pytest - Zero external dependencies
pip install askputfrom askput import ask
age = ask.int("Enter age", min=18)
price = ask.float("Enter price", min=0)
name = ask.string("Enter name", min_len=2)
email = ask.email("Enter email")
print(age, price, name, email)from askput import ask
age = ask.int("Enter age", min=18)
price = ask.float("Enter price", min=0)
name = ask.string("Enter name", min_len=2)
email = ask.email("Enter email")
print(age, price, name, email)from askput import ask
password = ask.password("Enter password")
strong_password = ask.password_strong("Create strong password")
confirm = ask.confirm("Continue?")
delete = ask.confirm_phrase("Type DELETE to continue", "DELETE")from askput import ask
role = ask.choice(
"Select role",
["Admin", "User", "Guest"]
)
print("Selected role:", role)from askput import ask
code = ask.pattern("Enter code", r"^[A-Z]{3}\d{3}$")
tags = ask.multi("Enter tags (comma separated)")
print(code, tags)from askput import ask
role = ask.choice("Role", ["Admin", "User"])
age = ask.int("Age", min=18)
password = ask.password_strong("Password")
if ask.confirm("Submit form?"):
print("Form submitted")askput is fully tested using pytest.
pytestAll tests are before every release.