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

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.

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-1.0.1.tar.gz (7.0 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for python-editor-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8672e9a44a7957741453dd35e842299f6c29f0a88dc9e4316b0fa5935abb9186
MD5 e1fa63535b40e022fa4fd646fd8b511a
BLAKE2b-256 2bc0df7b87d5cf016f82eab3b05cd35f53287c1178ad8c42bfb6fa61b89b22f6

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