Skip to main content

Programmatically open an editor, capture the result.

Project description

python-editor is a library that provides the editor module for programmatically interfacing with your system’s $EDITOR.

Examples

`python import editor commit_msg = editor.edit(contents=b"# Enter commit message here") `

Opens an editor, prefilled with the contents, # Enter commit message here. When the editor is closed, returns the contents (bytes) in variable commit_msg. Note that the argument to contents needs to be a bytes object on Python 3.

`python editor.edit(file="README.txt") `

Opens README.txt in an editor. Changes are saved in place. If there is a contents argument then the file contents will be overwritten.

`python editor.edit(..., use_tty=True) `

Opens the editor in a TTY. This is usually done in programs which output is piped to other programs. In this case the TTY is used as the editor’s stdout, allowing interactive usage.

How it Works

editor first looks for the ${EDITOR} environment variable. If set, it uses the value as-is, without fallbacks.

If no $EDITOR is set, editor will search through a list of known editors, and use the first one that exists on the system.

For example, on Linux, editor will look for the following editors in order:

  • vim

  • emacs

  • nano

When calling editor.edit, an editor will be opened in a subprocess, inheriting the parent process’s stdin, stdout.

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

python-editor-1.0.4.tar.gz (7.1 kB view details)

Uploaded Source

Built Distributions

python_editor-1.0.4-py3.5.egg (3.1 kB view details)

Uploaded Source

python_editor-1.0.4-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

python_editor-1.0.4-py2.7.egg (5.0 kB view details)

Uploaded Source

python_editor-1.0.4-py2-none-any.whl (4.9 kB view details)

Uploaded Python 2

File details

Details for the file python-editor-1.0.4.tar.gz.

File metadata

  • Download URL: python-editor-1.0.4.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.12

File hashes

Hashes for python-editor-1.0.4.tar.gz
Algorithm Hash digest
SHA256 51fda6bcc5ddbbb7063b2af7509e43bd84bfc32a4ff71349ec7847713882327b
MD5 0e52648a4a6e7c89e3be44e9456530b4
BLAKE2b-256 0a8578f4a216d28343a67b7397c99825cff336330893f00601443f7c7b2f2234

See more details on using hashes here.

File details

Details for the file python_editor-1.0.4-py3.5.egg.

File metadata

  • Download URL: python_editor-1.0.4-py3.5.egg
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.12

File hashes

Hashes for python_editor-1.0.4-py3.5.egg
Algorithm Hash digest
SHA256 c3da2053dbab6b29c94e43c486ff67206eafbe7eb52dbec7390b5e2fb05aac77
MD5 4bacb5fdc2027939c6c60228544fb551
BLAKE2b-256 5234477695c3a37d921dba1bd0856c756525276bd42adc7ccfc6bf82f3778a26

See more details on using hashes here.

File details

Details for the file python_editor-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: python_editor-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.12

File hashes

Hashes for python_editor-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1bf6e860a8ad52a14c3ee1252d5dc25b2030618ed80c022598f00176adc8367d
MD5 620d31cf0d2f25a2da21852f5a1a6090
BLAKE2b-256 c6d3201fc3abe391bbae6606e6f1d598c15d367033332bd54352b12f35513717

See more details on using hashes here.

File details

Details for the file python_editor-1.0.4-py2.7.egg.

File metadata

  • Download URL: python_editor-1.0.4-py2.7.egg
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.12

File hashes

Hashes for python_editor-1.0.4-py2.7.egg
Algorithm Hash digest
SHA256 ea87e17f6ec459e780e4221f295411462e0d0810858e055fc514684350a2f522
MD5 95ddcf2f37857bb4d06b3bcce537fd6a
BLAKE2b-256 bce3019ed6d1a5a5e837739de55cda27b2f03045c9f9d84054b97e79a86fe2fc

See more details on using hashes here.

File details

Details for the file python_editor-1.0.4-py2-none-any.whl.

File metadata

  • Download URL: python_editor-1.0.4-py2-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.12

File hashes

Hashes for python_editor-1.0.4-py2-none-any.whl
Algorithm Hash digest
SHA256 5f98b069316ea1c2ed3f67e7f5df6c0d8f10b689964a4a811ff64f0106819ec8
MD5 fc42eeb8edc379020c4a5983daef4941
BLAKE2b-256 55a03c0ba1c10f2ca381645dd46cb7afbb73fddc8de9f957e1f9e726a846eabc

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