Skip to main content

Because nobody types exactly 'Y' or 'N'. Accepts human-flavored yes/no/maybe input.

Project description

rich-input-handlr

Because nobody types exactly Y or N.

PyPI version Python versions License: GPLv3 Zero dependencies Tests

a Python lib that accepts human-flavored yes/no input and gives you back a clean True / False / None. understands slang, uwu-speak, profanity, typos, multilingual stuff, and the full spectrum of how people actually answer shit.

"You sure wanna download Miku songs? (yes/no): fuck yeah"
→ True

install

pip install rich-input-handlr

quick start

from rich_input_handlr import ask

if ask("Wanna overwrite this file?"):
    overwrite()
else:
    print("okay skipping lol")

that's literally it. ask() prints your question, reads input, returns True, False, or None. no more babysitting users who can't type a capital Y.


what it understands

YES → True

yes, y, yeah, yep, yup, sure, absolutely, ofc, bet, fr, no cap, hell yeah, fuck yeah, yass, yas, lets go, lesgo, im in, yesh, yus, oki, si, oui, ja, da, and like 50 more

NO → False

no, n, nope, nah, nay, never, negative, hell no, fuck no, hard pass, pass, nuh uh, not a chance, L, big L, nein, niet, non, and like 50 more

UNCERTAIN → None or random (your call)

idk, maybe, meh, eh, depends, kinda, sorta, whatever, idrc, 50/50, dunno, perhaps, flip a coin, and more


full config

wanna customize stuff? instantiate RichInput directly:

from rich_input_handlr import RichInput

handler = RichInput(
    uncertain_behavior="random",   # "random" | "none" | "prompt"
    fuzzy_threshold=0.82,          # 0.0–1.0 — lower = more lenient with typos
    extra_yes=["affirmativo"],     # add your own YES words
    extra_no=["no bueno"],         # add your own NO words
    extra_uncertain=["on the fence"],
    prompt_suffix=" (yes/no): ",   # appended to your question
)

result = handler.ask("Continue?")

uncertain_behavior options

value what happens on "idk" / "meh" / unrecognized input
"random" randomly returns True or False (50/50, default)
"none" always returns None, you deal with it
"prompt" re-asks the user once, then gives up and returns None

async support

yep it's async-ready too

import asyncio
from rich_input_handlr import RichInput

handler = RichInput()

async def main():
    result = await handler.ask_async("Proceed?")
    print(result)

asyncio.run(main())

parse without prompting

already have the input from somewhere else (a bot, a GUI, whatever)? skip the prompt:

handler.parse("hell yeah")   # → True
handler.parse("nah fam")     # → False
handler.parse("idk man")     # → None or random, depends on your uncertain_behavior

async version:

await handler.parse_async("yup")  # → True

fuzzy matching

typos handled via Python's built-in difflib.SequenceMatcher. default threshold is 0.82 — catches stuff like "yse", "noo", "mabe" without going too crazy with false positives.

loosen it up if you want:

handler = RichInput(fuzzy_threshold=0.65)  # more lenient

return values

situation returns
recognized YES True
recognized NO False
uncertain/unrecognized + uncertain_behavior="none" None
uncertain/unrecognized + uncertain_behavior="random" True or False
uncertain/unrecognized + uncertain_behavior="prompt" re-asks; None if still unclear

zero dependencies

pure stdlib only — difflib, random, asyncio. nothing to install, nothing to break, nothing to audit.


license

GPL-3.0

Youtube Channel - Donate - ...nothing else thx for using

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

rich_input_handlr-1.0.1.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

rich_input_handlr-1.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file rich_input_handlr-1.0.1.tar.gz.

File metadata

  • Download URL: rich_input_handlr-1.0.1.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for rich_input_handlr-1.0.1.tar.gz
Algorithm Hash digest
SHA256 13fdd53402c8db9a0670ac3485c2a2b3f018b0cd7bb1bbac85ebfbc9ae7f97ed
MD5 581459b6503cd61403f27661c6da4f4e
BLAKE2b-256 e3a4da1d8d6d4e57a9871b0132648970101d3bbd9faca4787b018cf0a45aeeb3

See more details on using hashes here.

File details

Details for the file rich_input_handlr-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for rich_input_handlr-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 380ae0fea7742f4f5d7637380b3944c9c823d23fed0c8c4855917f1890435347
MD5 28d5dd186f5fa14a02da092e4a76c345
BLAKE2b-256 91cb64eae3f7459798a84c4e994719b94b9e1aee963faf72323a1471aaffe3d1

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