Python Prompt Toolkit: A python tool library for building powerful interactive command lines
prompt_toolkit
is 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_toolkit
Can 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