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.

Files for python-editor, version 0.5
Filename, size File type Python version Upload date Hashes
Filename, size python_editor-0.5-py2.7.egg (4.0 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size python-editor-0.5.tar.gz (6.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page