Skip to main content

🎯 Simple and safe console input validation for Python

Project description

askput

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.


Why askput?

Python’s built-in input():

  • always returns strings
  • provides no validation
  • leads to repeated try / except blocks

askput offers a clean abstraction over these problems while staying simple and dependency-free.


Features

  • 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

Installation

pip install askput

Usages

Basic Usage

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)

Passwords and Confirmations

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")

Choice / Menu Input

from askput import ask

role = ask.choice(
    "Select role",
    ["Admin", "User", "Guest"]
)

print("Selected role:", role)

##Pattern and Multiple Input

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)

Example: Simple CLI Flow

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")

Testing

askput is fully tested using pytest.

pytest

All tests are before every release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

askput-0.1.4.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

askput-0.1.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file askput-0.1.4.tar.gz.

File metadata

  • Download URL: askput-0.1.4.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.7

File hashes

Hashes for askput-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b26983dc1655de42ddd7e264433dd159963000da8b18e4b70a2f66ab0ea3df4a
MD5 8f8a265bd9682e253ea91c7ca3e88b7a
BLAKE2b-256 9b7e688ed0f6392635e6e70a6b4dddfd6bd50012d1e558f9414f760019ad0e8d

See more details on using hashes here.

File details

Details for the file askput-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: askput-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.7

File hashes

Hashes for askput-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9a520b3a60430962da48f51b9226ca6b50a5e9e08c3ce279f9127a3d7be699f4
MD5 d6dfc143e6147c06721487ca541f0c3f
BLAKE2b-256 ed9be86af3f3c4b8fbe9beeba499853065bb1de21fd55c0e7a8e87847e010f42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page