Framework for generating formatted user input questions.
Project description
MultiChoice
A framework for generating well formatted user input queries in the terminal.
Table of Contents
- API Documentation
- Question: Fill-in-the-blank
- TrueFalse: True or False
- MultiChoice: Multiple Choice
- Developer Log
API Documentation
Class: Question
Question(query)
Question: Generates fill in the blank style questions.
__call__(self)
- Return: String. Returns the user selection.
__init__(self, query, required=True, cursor='>>>')
- Param query: String.
- Question for the user.
- Param required: Optional Bool. Default=True
- True: Repeats question until answered.
- False: Accepts null input as an empty string.
- Param cursor: Optional String. Default='>>>'
- Indicates user input field.
Question Example
from MultiChoice import Question
get_name = Question("What is your name?") # setup
user = get_name() # get input
print(user) # print
What is your name?
>>> Robert
Robert
Class: TrueFalse
TrueFalse(query)
TrueFalse: Generates True or False style questions.
__call__(self)
- Return: String. Returns the user selection.
__init__(self, query, required=True, strict=True, cursor='>>>')
- Param query: String.
- Question for the user.
- Param required: Optional Bool. Default=True
- True: Repeats question until answered.
- False: Accepts null input as an empty string.
- Param strict: Optional Bool. Default=True
- True: Answer must be in the options tuple. Not case-sensitive.
- False: Accepts any answer.
- Param cursor: Optional String. Default='>>>'
- Indicates user input field.
TrueFalse Example
from MultiChoice import TrueFalse
question = TrueFalse("True or False: Python3 is the best!")
answer = question()
print(answer)
True or False: Python3 is the best!
1. True
2. False
>>> 1
True
Class: MultiChoice
MultiChoice(query, options)
MultiChoice: Generates multiple choice style questions.
__call__(self)
- Return: String. Returns the user selection.
__init__(self, query, options, required=True, strict=True, cursor='>>>')
- Param query: String.
- Question for the user.
- Param options: Tuple of Strings.
- Options presented to the user as a numbered sequence.
- Numbers are generated automatically.
- The user may enter an answer as text or one of the numbers.
- Param required: Optional Bool. Default=True.
- True: Repeats question until answered.
- False: Accepts null input as an empty string.
- Param strict: Optional Bool. Default=True.
- True: Answer must be in the options tuple. Not case-sensitive.
- False: Accepts any answer.
- Param cursor: Optional String. Default='>>>'
- Indicates user input field.
MultiChoice Example
from MultiChoice import MultiChoice
question = MultiChoice(
"What is your favorite color?\n"
"You must choose one of the following:",
options=("Red", "Orange", "Yellow", "Green", "Blue", "Purple"),
)
answer = question()
print(answer)
What is your favorite color?
You must choose one of the following:
1. Red
2. Orange
3. Yellow
4. Green
5. Blue
6. Purple
>>> blue
Blue
Developer Log
MultiChoice v0.3.3
- Comments Updated
MultiChoice v0.3.2
- Examples Added
MultiChoice v0.3.1
- Added Cursor Option
MultiChoice v0.2 (internal)
- API Updated
MultiChoice v0.1
- Initial Upload
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
Built Distribution
File details
Details for the file MultiChoice-0.3.3.tar.gz
.
File metadata
- Download URL: MultiChoice-0.3.3.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.4.2 requests/2.20.0 setuptools/41.4.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4faecd55f5afecfc09cc19298be2a67c48f73082310b925d87d8b5f8b4c47592 |
|
MD5 | 40c4775813914d84ebd00e1b2a45461a |
|
BLAKE2b-256 | d031fde96e3512757743fc4ce73caabb7bd8c3b4a9d897e92aadb7aba9152030 |
File details
Details for the file MultiChoice-0.3.3-py3-none-any.whl
.
File metadata
- Download URL: MultiChoice-0.3.3-py3-none-any.whl
- Upload date:
- Size: 2.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.4.2 requests/2.20.0 setuptools/41.4.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 729703b12027b2a154559a93be6d634eb97cd88bb51bf4b73b3b6c82d5559c6c |
|
MD5 | 262ef014bbc2e64777a193c683db4f7c |
|
BLAKE2b-256 | 2a1f0b21fe304a67c3e669d16f8710d9260ed202cee218d3b74a072ab9dc5224 |