Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easyrepl-0.1.5.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

easyrepl-0.1.5-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file easyrepl-0.1.5.tar.gz.

File metadata

  • Download URL: easyrepl-0.1.5.tar.gz
  • Upload date:
  • Size: 4.1 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

Hashes for easyrepl-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c9610a6a1d6760cd3a8ca3255b75e8f12c83367597a03d96c16edee9f972039f
MD5 b2bac2ed05c84057324e66c709547eca
BLAKE2b-256 73780f307326020af8a51d3280d7e30bf91feeeb6f66a3da6839ad422dc34374

See more details on using hashes here.

File details

Details for the file easyrepl-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: easyrepl-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.7 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

Hashes for easyrepl-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1d27e47cc9bd408d7e1832ffc19a827d429ed31f39047553e364a0fdcce26c6a
MD5 3d6ad519e1bdea70b92c6834b2546161
BLAKE2b-256 8cf17ba1f4d69a00127862f0c1df6b36537ca36ead2a34b1db9ed2e1b5a9c954

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page