better-rich-prompts 1.0.2

Last updated:

0 purchases

better-rich-prompts 1.0.2 Image
better-rich-prompts 1.0.2 Images
Add to Cart

Description:

betterrichprompts 1.0.2

English readme
better-rich-prompts is a Python extension library for Rich.
This Library makes it easy to use lists and dictionaries as choices for prompt.ask .
Compatibility
This library should work
Installing
python -m pip install better-rich-prompts

Using List Prompt
Example 1 - Using list of dictionaries
from better_rich_prompts.prompt import ListPrompt

choices = [
{"name": "english", "language_code": "en"},
{"name": "spanish", "language_code": "es"},
{"name":"french","language_code":"fr"},
]
ListPrompt.ask("Select a language", choices, choice_key="name")


Example 2 - Using list of strings
from better_rich_prompts.prompt import ListPrompt

choices = ["en", "es", "fr"]
ListPrompt.ask("Select a language", choices,default="en")


Example 3 - Using list of custom objects
from better_rich_prompts.prompt import ListPrompt

class Language:
def __init__(self, name, code):
self.name = name
self.code = code


choices = [
Language("english", "en"),
Language("spanish", "es"),
Language("french", "fr"),
]
ListPrompt.ask(
"Select a language", choices, default="en", choice_key=lambda c: c.code
)


Using Dict Prompt
from better_rich_prompts.prompt import DictPrompt

choices = {"en":"english","es":"spanish","fr":"french"}
DictPrompt.ask("Select a language", choices)

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.