1001 Ways to Play | Python Prompt Toolkit: A python tool library for building powerful interactive command lines

Source: Internet
Author: User

Python Prompt Toolkit: A python tool library for building powerful interactive command lines

prompt_toolkitis a Python tool library for building powerful interactive command lines.

Are you looking for an interactive Python shell tool ptpython ? We have ptpython transferred the source code to a separate warehouse. In this way, we are sure that the prompt_toolkit library will not be ptpython "contaminated" by other things and ptpython can be developed independently. You must now install it with the following command ptpython :

Pip install ptpython

Characteristics of Prompt-toolkit Features

prompt_toolkitCan be used as a substitute for the GNU ReadLine, but it's actually much better than the latter.

Some features:

    • Pure Python;

    • Support syntax highlighting when typing; (with pygments lexical analyzer)

    • Support multi-line input editing;

    • Advanced code completion;

    • Supports Emacs and Vi hotkey bindings; (similar to ReadLine)

    • Support for reverse and forward incremental search;

    • Support for Python versions between 2.6 and 3.4;

    • Supports Unicode double-wide characters; (e.g.: Chinese input)

    • Select text Copy/paste (Both Emacs and Vi style.)

    • Multiple input cache

    • Lightweight, relying only on pygments, six and wcwidth;

    • Code written with Love.

    • Support for Linux, OS X, OpenBSD and Windows systems;

Installation

Pip Install prompt-toolkit

Getting Started

Let's start with a simple example:

From prompt_toolkit. Shortcuts import get_input

If __name__ = = ' __main__ ':

answer = get_input(' Give me some input: ')

Print(' you said:%s ' % answer)

For a complex example, look at the examples table of contents. The selected examples are straight one thing. Don't be afraid to look at the source code OH. The implementation of the get_input function is a good start.

Note: Under Python 2, you need to add to the above example from __future__ import unicode_literals  . All characters are treated as Unicode characters.

Open source projects using Prompt-toolkit

    • Ptpython:python REPL

    • Ptpdb:python Debugger (PDB substitute)

    • Pgcli:postgres client.

    • Mycli:mysql client.

    • Pyvim: Pure Python-implemented Vim clone version

    • Wharfee:docker command-line tools

    • New Wisdom Cloud Official website www.enncloud.cn

1001 Ways to Play | Python Prompt Toolkit: A python tool library for building powerful interactive command lines

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.