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.0.tar.gz (8.1 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.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rich_input_handlr-1.0.0.tar.gz
  • Upload date:
  • Size: 8.1 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.0.tar.gz
Algorithm Hash digest
SHA256 5e64042731840270677446aea47a4c19038490eddb3bdbe09274f43e6529d436
MD5 4ac99fb69314129f5cb58c639603ea6f
BLAKE2b-256 5fa7934facb5d3b146d90b32cfae8e265868e0255c3c6340102bd3dbbd9e44a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rich_input_handlr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a0fa9eefaad55f9282bdd77d3f22acefe7acdfe14fecf2e2204d95d6da056dd
MD5 9ce83dab51b4229b18ca634701145871
BLAKE2b-256 d414f8e1e1a92ad527c8a7e0adfdcbb26987bafbf63bd34c9ffa41733b8fdff5

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