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="# Enter commit message here") ` Opens an editor, prefilled with the contents, # Enter commit message here. When the editor is closed, returns the contents in variable commit_msg.

`python import editor editor.edit(file="README.txt") ` Opens README.txt in an editor. Changes are saved in place.

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 the edit() function, editor will open the editor 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-0.4.tar.gz (6.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: python-editor-0.4.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for python-editor-0.4.tar.gz
Algorithm Hash digest
SHA256 4421a7116bf3af957266f225bc79ad25b92839cc7974c8335bba5a6582edd3bf
MD5 30de680ec944d073e0c3f18b44d5aa15
BLAKE2b-256 d52c16cbe80d7a647aafad903d4b6784e3c5622faf5170dc3c6661e1f9bb0380

See more details on using hashes here.

Supported by

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