# Ask Question












[](https://www.buymeacoffee.com/hanra)
## Description
This is a python package I created in order to simplify the boiling process when asking the user a question via TTY or TUI (Terminal User Interface).
## Table of Content
1. [ask_question](#ask-question)
2. [Description](#description)
3. [Table of Content](#table-of-content)
4. [Installation](#installation)
1. [Using pip](#using-pip)
2. [Using python](#using-python)
5. [Usage](#usage)
1. [Importing](#importing)
2. [Initialising](#initialising)
3. [Calling the pause function](#calling-the-pause-function)
4. [Asking a question](#asking-a-question)
1. [Where do you live ?](#where-do-you-live)
2. [How old are you ?](#how-old-are-you)
3. [Do you like sugar ?](#do-you-like-sugar)
6. [Available boiling](#available-boiling)
7. [Change the initialisation content](#change-the-initialisation-content)
1. [Changing the forbidden characters](#changing-the-forbidden-characters)
2. [Changing the description](#changing-the-descriptions)
3. [Changing both](#changing-both)
8. [Author](#author)
9. [Note to the devs](#note-to-the-devs)
## Installation
### Using pip
```sh
pip install -U ask-question
```
### Using python
Under windows:
```bat
py -m pip install -U ask-question
```
Under Linux/Mac OS:
```sh
python3 -m pip install -U ask-question
```
## Usage
### Importing
```py
import ask_question as aq
```
### Initialising
The generic class is: `AskQuestion(human_type: dict = {}, illegal_characters_nb: str = "", tui: bool = False, allow_blank: bool = False)`
```py
AQI = aq.AskQuestion()
```
### Calling the pause function
The generic function is:
```py
pause(self, pause_message: str = "Press enter to continue...")
```
The output is: None
```py
AQI.pause("Press enter to continue...")
```
### Asking a Question
The generic function to ask a question is:
```py
ask_question(self, question: str, answer_type: str)
```
The outputs of this functions can be:
* str = a string
* int = a whole number
* float = a floating number
* bool = a boolean value (True or False)
#### Where do you live
```py
answer = AQI.ask_question("Where are you from? ", "str")
print(f"You live in {answer}!")
```
#### How old are you
```py
answer = AQI.ask_question("How old are you?", "uint")
ADD_S = ""
if answer > 1:
ADD_S = "s"
print(f"You are {answer} year{ADD_S} old !")
```
#### Do you like sugar
```py
answer = AQI.ask_question("Do you like sugar? [(Y)es/(n)o]: ", "bool")
if answer == True:
print("You like sugar !")
else:
print("You do not like sugar.")
```
## Available boiling
Here are all the available boiling options and their explanation:
* int = whole number (-1, 0, 1, 2, 3, etc...)
* float = floating number (-1.2, 0.1, 1.2, etc...)
* uint = whole positive number (0, 1, 2, etc...)
* ufloat = whole positive floating number (0.1, 1.2, etc ...)
* num = numeric (numbers from 0 onwards)
* alnum = alphanumeric (only numbers and the alphabet)
* alpha = alphabet (from a to z and A to Z)
* char = alphabet (from a to z and A to Z)
* ascii = ascii Table
* str = string (any character you can type)
* version = version (numbers separated by '.' characters)
* ver = version (numbers separated by '.' characters)
* bool = boolean (yes/True/1 or no/False/0 answer type)
## Change the initialisation content
When initialising the class it is possible to change the forbidden characters and/or the descriptions of the available types.
### changing the forbidden characters
```py
import ask_question as aq
illegal_characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \\t\\n\\r\\x0b\\x0c"
illegal_characters = illegal_characters.replace("0123456789","")
AQI = aq.AskQuestion(dict(), illegal_characters)
```
This initialisation has changed the characters that will be allowed for the number conversion in the 'int' and 'float' options.
### Changing the descriptions
```py
import ask_question as aq
human_type = {
"int":"whole number (-1, 0, 1, 2, 3, etc...)",
"float":"floating number (-1.2, 0.1, 1.2, etc...)",
"uint":"whole positive number (0, 1, 2, etc...)",
"ufloat":"whole positive floating number (0.1, 1.2, etc ...)",
"num":"numeric (numbers from 0 onwards)",
"alnum":"alphanumeric (only numbers and the alphabet)",
"alpha":"alphabet (from a to z and A to Z)",
"char":"alphabet (from a to z and A to Z)",
"ascii":"ascii Table",
"str":"string (any character you can type)",
"version":"version (numbers separated by '.' characters)",
"ver":"version (numbers separated by '.' characters)",
"bool":"boolean (yes/True/1 or no/False/0 answer type)",
}
AQI = aq.AskQuestion(human_type)
```
This initialisation has changed the descriptions for the types.
When the user will enter a wrong answer, the description displayed for the type you were expecting will be taken from the human_type dictionnary you have entered.
### Changing both
```py
import ask_question as aq
illegal_characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \\t\\n\\r\\x0b\\x0c"
illegal_characters = illegal_characters.replace("0123456789","")
human_type = {
"int":"whole number (-1, 0, 1, 2, 3, etc...)",
"float":"floating number (-1.2, 0.1, 1.2, etc...)",
"uint":"whole positive number (0, 1, 2, etc...)",
"ufloat":"whole positive floating number (0.1, 1.2, etc ...)",
"num":"numeric (numbers from 0 onwards)",
"alnum":"alphanumeric (only numbers and the alphabet)",
"alpha":"alphabet (from a to z and A to Z)",
"char":"alphabet (from a to z and A to Z)",
"ascii":"ascii Table",
"str":"string (any character you can type)",
"version":"version (numbers separated by '.' characters)",
"ver":"version (numbers separated by '.' characters)",
"bool":"boolean (yes/True/1 or no/False/0 answer type)",
}
AQI = aq.AskQuestion(human_type)
```
You have now impacted the int and float typing as well as the 'type' descriptions.
## Author
This module was written by (c) Henry Letellier
Attributions are appreciated.
Quick way (I assume you have already initialised the class):
```py
print(f"AskQuestion is written by {AQI.author}")
```
## Running unit tests
Although they might not be bundled in the module itself, you can clone the source repository, intall the requirement at the root and run `pytest -s` at the root of the repository to see the result.
## Note to the devs
Due to the update of the packaging methods (switching from setup.py to pyproject.toml) and for package stability tracking reasons, it is now required (or strongly suggested) you remove the resulting ask_question package that gets installed alongside with it's dependencies.
You can do so with the following command: `pip uninstall ask_question -y`
Raw data
{
"_id": null,
"home_page": null,
"name": "ask-question",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Henry Letellier <henrysoftwarehouse@protonmail.com>",
"keywords": "tty, tui, cli, survey, python, prompt, question, user input, automation, interactive, asciimatics",
"author": null,
"author_email": "Henry Letellier <henrysoftwarehouse@protonmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a5/cf/cbd1860849925d0be42735ab910609b9a82a887c9aec42f5a2752c5f1c07/ask_question-1.2.12.tar.gz",
"platform": null,
"description": "# Ask Question\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[](https://www.buymeacoffee.com/hanra)\n\n## Description\n\nThis is a python package I created in order to simplify the boiling process when asking the user a question via TTY or TUI (Terminal User Interface).\n\n## Table of Content\n\n1. [ask_question](#ask-question)\n2. [Description](#description)\n3. [Table of Content](#table-of-content)\n4. [Installation](#installation)\n 1. [Using pip](#using-pip)\n 2. [Using python](#using-python)\n5. [Usage](#usage)\n 1. [Importing](#importing)\n 2. [Initialising](#initialising)\n 3. [Calling the pause function](#calling-the-pause-function)\n 4. [Asking a question](#asking-a-question)\n 1. [Where do you live ?](#where-do-you-live)\n 2. [How old are you ?](#how-old-are-you)\n 3. [Do you like sugar ?](#do-you-like-sugar)\n6. [Available boiling](#available-boiling)\n7. [Change the initialisation content](#change-the-initialisation-content)\n 1. [Changing the forbidden characters](#changing-the-forbidden-characters)\n 2. [Changing the description](#changing-the-descriptions)\n 3. [Changing both](#changing-both)\n8. [Author](#author)\n9. [Note to the devs](#note-to-the-devs)\n\n## Installation\n\n### Using pip\n\n```sh\npip install -U ask-question\n```\n\n### Using python\n\nUnder windows:\n\n```bat\npy -m pip install -U ask-question\n```\n\nUnder Linux/Mac OS:\n\n```sh\npython3 -m pip install -U ask-question\n```\n\n## Usage\n\n### Importing\n\n```py\nimport ask_question as aq\n```\n\n### Initialising\n\nThe generic class is: `AskQuestion(human_type: dict = {}, illegal_characters_nb: str = \"\", tui: bool = False, allow_blank: bool = False)`\n\n```py\nAQI = aq.AskQuestion()\n```\n\n### Calling the pause function\n\nThe generic function is:\n\n```py\npause(self, pause_message: str = \"Press enter to continue...\")\n```\n\nThe output is: None\n\n```py\nAQI.pause(\"Press enter to continue...\")\n```\n\n### Asking a Question\n\nThe generic function to ask a question is:\n\n```py\nask_question(self, question: str, answer_type: str)\n```\n\nThe outputs of this functions can be:\n\n* str = a string\n* int = a whole number\n* float = a floating number\n* bool = a boolean value (True or False)\n\n#### Where do you live\n\n```py\nanswer = AQI.ask_question(\"Where are you from? \", \"str\")\nprint(f\"You live in {answer}!\")\n```\n\n#### How old are you\n\n```py\nanswer = AQI.ask_question(\"How old are you?\", \"uint\")\nADD_S = \"\"\nif answer > 1:\n ADD_S = \"s\"\nprint(f\"You are {answer} year{ADD_S} old !\")\n```\n\n#### Do you like sugar\n\n```py\nanswer = AQI.ask_question(\"Do you like sugar? [(Y)es/(n)o]: \", \"bool\")\nif answer == True:\n print(\"You like sugar !\")\nelse:\n print(\"You do not like sugar.\")\n```\n\n## Available boiling\n\nHere are all the available boiling options and their explanation:\n\n* int = whole number (-1, 0, 1, 2, 3, etc...)\n* float = floating number (-1.2, 0.1, 1.2, etc...)\n* uint = whole positive number (0, 1, 2, etc...)\n* ufloat = whole positive floating number (0.1, 1.2, etc ...)\n* num = numeric (numbers from 0 onwards)\n* alnum = alphanumeric (only numbers and the alphabet)\n* alpha = alphabet (from a to z and A to Z)\n* char = alphabet (from a to z and A to Z)\n* ascii = ascii Table\n* str = string (any character you can type)\n* version = version (numbers separated by '.' characters)\n* ver = version (numbers separated by '.' characters)\n* bool = boolean (yes/True/1 or no/False/0 answer type)\n\n## Change the initialisation content\n\nWhen initialising the class it is possible to change the forbidden characters and/or the descriptions of the available types.\n\n### changing the forbidden characters\n\n```py\nimport ask_question as aq\nillegal_characters = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\\\"#$%&\\'()*+,-./:;<=>?@[\\\\]^_`{|}~ \\\\t\\\\n\\\\r\\\\x0b\\\\x0c\"\nillegal_characters = illegal_characters.replace(\"0123456789\",\"\")\nAQI = aq.AskQuestion(dict(), illegal_characters)\n```\n\nThis initialisation has changed the characters that will be allowed for the number conversion in the 'int' and 'float' options.\n\n### Changing the descriptions\n\n```py\nimport ask_question as aq\nhuman_type = {\n \"int\":\"whole number (-1, 0, 1, 2, 3, etc...)\",\n \"float\":\"floating number (-1.2, 0.1, 1.2, etc...)\",\n \"uint\":\"whole positive number (0, 1, 2, etc...)\",\n \"ufloat\":\"whole positive floating number (0.1, 1.2, etc ...)\",\n \"num\":\"numeric (numbers from 0 onwards)\",\n \"alnum\":\"alphanumeric (only numbers and the alphabet)\",\n \"alpha\":\"alphabet (from a to z and A to Z)\",\n \"char\":\"alphabet (from a to z and A to Z)\",\n \"ascii\":\"ascii Table\",\n \"str\":\"string (any character you can type)\",\n \"version\":\"version (numbers separated by '.' characters)\",\n \"ver\":\"version (numbers separated by '.' characters)\",\n \"bool\":\"boolean (yes/True/1 or no/False/0 answer type)\",\n}\nAQI = aq.AskQuestion(human_type)\n```\n\nThis initialisation has changed the descriptions for the types.\nWhen the user will enter a wrong answer, the description displayed for the type you were expecting will be taken from the human_type dictionnary you have entered.\n\n### Changing both\n\n```py\nimport ask_question as aq\nillegal_characters = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\\\"#$%&\\'()*+,-./:;<=>?@[\\\\]^_`{|}~ \\\\t\\\\n\\\\r\\\\x0b\\\\x0c\"\nillegal_characters = illegal_characters.replace(\"0123456789\",\"\")\nhuman_type = {\n \"int\":\"whole number (-1, 0, 1, 2, 3, etc...)\",\n \"float\":\"floating number (-1.2, 0.1, 1.2, etc...)\",\n \"uint\":\"whole positive number (0, 1, 2, etc...)\",\n \"ufloat\":\"whole positive floating number (0.1, 1.2, etc ...)\",\n \"num\":\"numeric (numbers from 0 onwards)\",\n \"alnum\":\"alphanumeric (only numbers and the alphabet)\",\n \"alpha\":\"alphabet (from a to z and A to Z)\",\n \"char\":\"alphabet (from a to z and A to Z)\",\n \"ascii\":\"ascii Table\",\n \"str\":\"string (any character you can type)\",\n \"version\":\"version (numbers separated by '.' characters)\",\n \"ver\":\"version (numbers separated by '.' characters)\",\n \"bool\":\"boolean (yes/True/1 or no/False/0 answer type)\",\n}\nAQI = aq.AskQuestion(human_type)\n```\n\nYou have now impacted the int and float typing as well as the 'type' descriptions.\n\n## Author\n\nThis module was written by (c) Henry Letellier\nAttributions are appreciated.\n\nQuick way (I assume you have already initialised the class):\n\n```py\nprint(f\"AskQuestion is written by {AQI.author}\")\n```\n\n## Running unit tests\n\nAlthough they might not be bundled in the module itself, you can clone the source repository, intall the requirement at the root and run `pytest -s` at the root of the repository to see the result.\n\n## Note to the devs\n\nDue to the update of the packaging methods (switching from setup.py to pyproject.toml) and for package stability tracking reasons, it is now required (or strongly suggested) you remove the resulting ask_question package that gets installed alongside with it's dependencies.\n\nYou can do so with the following command: `pip uninstall ask_question -y`\n",
"bugtrack_url": null,
"license": null,
"summary": "A module that simplifies the boiling process when asking the user a question via a TTY interface. (A TUI version is being developed, to call it, just add TUI at the end of the class name)",
"version": "1.2.12",
"project_urls": {
"Documentation": "https://github.com/Hanra-s-work/ask_question/blob/main/README.md",
"Homepage": "https://github.com/Hanra-s-work/ask_question",
"Issues": "https://github.com/Hanra-s-work/ask_question/issues",
"Repository": "https://github.com/Hanra-s-work/ask_question.git"
},
"split_keywords": [
"tty",
" tui",
" cli",
" survey",
" python",
" prompt",
" question",
" user input",
" automation",
" interactive",
" asciimatics"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "80972dfb57ca434f00853b88b53901d94d6bd9fe292c087d78602c0fc7029a2a",
"md5": "91f76de3a3dcf5e55dc5a70ff7096152",
"sha256": "7eaf087122d43acaa43bfcf6bb0264567c8cdb75de121cd252b81c4aa4c968a0"
},
"downloads": -1,
"filename": "ask_question-1.2.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "91f76de3a3dcf5e55dc5a70ff7096152",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 12419,
"upload_time": "2025-07-14T17:41:32",
"upload_time_iso_8601": "2025-07-14T17:41:32.984245Z",
"url": "https://files.pythonhosted.org/packages/80/97/2dfb57ca434f00853b88b53901d94d6bd9fe292c087d78602c0fc7029a2a/ask_question-1.2.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a5cfcbd1860849925d0be42735ab910609b9a82a887c9aec42f5a2752c5f1c07",
"md5": "8b3ba5568938a0b7533555ad69ead512",
"sha256": "07e4623563a4d76ddcf516a5640bbe5e6f0be79ed8811102c8fdb3cea2d6463e"
},
"downloads": -1,
"filename": "ask_question-1.2.12.tar.gz",
"has_sig": false,
"md5_digest": "8b3ba5568938a0b7533555ad69ead512",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 14889,
"upload_time": "2025-07-14T17:41:33",
"upload_time_iso_8601": "2025-07-14T17:41:33.844952Z",
"url": "https://files.pythonhosted.org/packages/a5/cf/cbd1860849925d0be42735ab910609b9a82a887c9aec42f5a2752c5f1c07/ask_question-1.2.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-14 17:41:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Hanra-s-work",
"github_project": "ask_question",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "ask-question"
}