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

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for python-editor-1.0.tar.gz
Algorithm Hash digest
SHA256 4a2b6a945d06e347a8fafe2475f533d05887b193b2e162aff961f63642c8a60e
MD5 a5ead611360b17b52507297d8590b4e8
BLAKE2b-256 f5d901eb441489c8bd2adb33ee4f3aea299a3db531a584cb39c57a0ecf516d9c

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