Skip to main content

enquiries aims to provide a straightforward way to get decisions from your users. It can offer multiple choice, yes/no or free text

import enquiries

options = ['thing 1', 'thing 2', 'thing 3']
choice = enquiries.choose('Choose one of these options: ', options)

if enquiries.confirm('Do you want to write something?'):
    text = enquiries.freetext('Write something interesting: ')
    print(text)

Input for these questions is fully interactive and prevents any incorrect responses. No more loops checking if the answer matches the question. No more mapping the text entered to original objects. Let users choose the objects directly.

https://asciinema.org/a/6OyuQH9H03vSP2gf79f0KwaCO.png

Multiple choice

All choices consist of letting users pick one of several items. For enquiries these can be in any iterable.

Users can pick one or many of the options offered to them.

Single Selection

For single choice, use the choose method with the list of choices.

>>> options = ['Thing 1', 'Thing 2']
>>> response = enquiries.choose('Pick a thing', options)
# interactive prompt
>>> print('You chose "{}"'.format(response))
You chose "Thing 1"
>>>

The interactive prompt here appears as list of options you can scroll through and select using the return key:

Pick a thing
> Thing 1
  Thing 2
  Thing 3

Where up/down arrow keys will scroll through the options moving the > marker. The currently selected option is also in bold typeface (if the terminal supports it).

Multiple Selections

For cases where the user can choose multiple options, the multi keyword can be used.

>>> options = ['Thing 1', 'Thing 2', 'Thing 3']
>>> response = enquiries.choose('Pick some things', options, multi=True)
# interactive prompt
>>> print('You chose "{}"'.format(response))
You chose "['Thing1', 'Thing 3']"
>>>

The interactive prompt for multiple choice is similar to that used for single choice but the > marker is replaces with ◉ and ◌ to signify chosen or not chosen. As before, the arrow keys change the selection and the current line is bold. The space key is used to mark an option as selected.:

pick a thing
◉ Thing 1
◌ Thing 2
◌ Thing 3

Yes/No Confirmation

Used to get a simple boolean response from users.

>>> if enquiries.confirm('Do you really want to do the thing')
...     print('Carrying on')
... else:
...     print('Exiting')
...
# interactive prompt
Carrying on
>>>

Results in the prompt below:

Do you really want to do the thing? [y/N]

The prompt for confirmation by default accepts y/n keys to choose and return to accept the choice. Return without choosing accepts the default value (usually False). The keys used and the default can be changed as required. By default, the user should choose y/n then hit return but single_key mode can be used to remove the need to hit return.

Freetext

enquiries free text offering is offers a slightly enhanced version of the input builtin function. It adds multi line support as well as basic readline like controls (Ctrl-a, Ctrl-w etc). The text entry area is also cleared after the text is accepted keeping terminal history clean.

>>> text = enquiries.freetext('Write some stuff')
>>> print(text)
This is the text you entered
on many lines
>>>

New lines in text can be entered using Alt-Return.

Release files for enquiries 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enquiries 0.2.0
File Size Uploaded
enquiries-0.2.0.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for enquiries 0.2.0
File Interpreter ABI Platform
enquiries-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.0 kB

Release files / enquiries-0.2.0.tar.gz

Download URL enquiries-0.2.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f151d67d24371586d8f9196423c7af8849987a3e406ff1750e99cb3256fd9521
BLAKE2b-256 checksum
How to use checksums
a7ffa31e613be5d4ece22bf6f469b116f53e5c56a564540f8b32945ac30f4ba2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.10 Linux/6.1.22-1-lts

Release files / enquiries-0.2.0-py3-none-any.whl

Download URL enquiries-0.2.0-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8d43455256077d167945cb819e5d897bc0465074e46d54fe683e71cd6eb6bb1
BLAKE2b-256 checksum
How to use checksums
2e1fe0ab93ace93d7f11b34e65f787e110827786a6cdf93d10dfebc997d8a65c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.10 Linux/6.1.22-1-lts

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page