A simple python class for creating Read Evaluate Print Line (REPL) interfaces
Project description
Easy REPL
A simple python class for creating Read Evaluate Print Line (REPL) interfaces.
Requirements
This module requires Python 3.7 or higher.
Additionally this library makes use of the GNU readline Interface, so it will only work on Unix based systems.
Usage
This module exposes the REPL
class which can be used to quickly create a REPL interface. REPL will read in a line of user input via a custom input function that allows you to edit the text by moving the cursor with the arrow keys, as well as view the history of previous inputs.
from easyrepl import REPL
for line in REPL():
# do something with line
print(line)
which will create a simple echoing REPL interface that repeats any line you type into it.
>>> hello
hello
>>> world
world
>>>
The input allows common terminal shortcuts like:
- Ctrl-D: exit REPL
- Ctrl-L: clear screen
- Ctrl-R: search history
- Left/Right Arrow: move cursor left/right
- Up/Down Arrow: previous/next history
- Ctrl-A: move cursor to beginning of line
- Ctrl-E: move cursor to end of line
- Alt-B: move cursor backward one word
- Alt-F: move cursor forward one word
- Ctrl-K: delete from cursor to end of line
- Ctrl-U: delete from cursor to beginning of line
- Ctrl-W: delete from cursor to beginning of word
- Alt-D: delete from cursor to end of word
- Ctrl-C: no operation
- etc.
Additionally, multi-line input can be achieved by starting a line with triple quotes ("""
or '''
), and ending the final line with a matching triple quote. Triple quotes in the middle of a line will have no effect.
>>> """
... This is a multi-line input
... that will continue until
... the user enters three quotes
... at the end of a line
... """
This is a multi-line input
that will continue until
the user enters three quotes
at the end of a line
>>>
Note that a single newline will be stripped from the beginning and end of the input if present.
Project details
Release history Release notifications | RSS feed
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 easyrepl-0.1.4.tar.gz
.
File metadata
- Download URL: easyrepl-0.1.4.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.7.16 Linux/5.18.19-051819-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 070309ae8f10a6e9ac252f3b3f3fadce2480365fbccde647228bc1856c39fd27 |
|
MD5 | bef2312720f5e82a11ed8cbe97f21427 |
|
BLAKE2b-256 | 998d4ff024a39d3a8aac7c798f182177f2be8dadc64c703cacaac27794911491 |
File details
Details for the file easyrepl-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: easyrepl-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.7.16 Linux/5.18.19-051819-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bf6c2e7b826ad824dcb05002f97b9f83124a91396613daf993f3523d39ca094 |
|
MD5 | 74c676d95060282ed19f8350f27b9539 |
|
BLAKE2b-256 | 0b2672a5037a3d30e96c7d993e4d4259c0d324b170b83e5575ce8e38d0b6f3cb |