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.2.tar.gz (25.7 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.2-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rich_input_handlr-1.0.2.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rich_input_handlr-1.0.2.tar.gz
Algorithm Hash digest
SHA256 36d2d310b1693e6fc3a3324d8c05702dd0989edad7846a2548bd86a268d3da54
MD5 d16a652dda0ac3b67ad04fc440ac71a0
BLAKE2b-256 b4e64e338b11887dd3db35c0e19b44b636a4dfde90bdd63d5202e6f2756eaf4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rich_input_handlr-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 20440259ce1b16c650f721502e91462610301323f45f3b2120f2dfd9cfd96655
MD5 1d8e3e420b085c65dc2b7517e3fc8d97
BLAKE2b-256 14a4f417452b6ae1be39bf14536df7d93f4eefd40ea4d6af8f1e447eb0cd24d3

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