Python Inquirer

3.4.1 · active · verified Thu Apr 09

Inquirer is a Python library that provides a collection of common interactive command-line user interfaces, based on the popular Inquirer.js. It aims to simplify asking questions, parsing and validating answers, and managing hierarchical prompts in CLI applications. The library is actively maintained and receives regular updates, with the current version being 3.4.1.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a list of different question types (Text, List, Confirm) and use `inquirer.prompt` to display them to the user, collecting the answers in a dictionary.

import inquirer

questions = [
    inquirer.Text('name', message="What's your name?"),
    inquirer.List(
        'size',
        message="What size do you need?",
        choices=['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro'],
    ),
    inquirer.Confirm('confirm', message="Proceed?")
]

answers = inquirer.prompt(questions)
print(f"Hello, {answers['name']}! You selected {answers['size']} and confirmed: {answers['confirm']}")

view raw JSON →