🖋 Open the default text editor 🖋
Project description
🖋 editor - Open a text editor 🖋
editor opens the default text editor or your favorite editor to edit an existing file,
a new file, or a tempfile, blocks while the user edits text, then returns the contents
of the file.
You can pass a parameter editor= to specify an editor or leave it empty, in which
case the editor is:
- The contents of the environment variable
VISUAL, if it's set, otherwise: - The the contents of the environment variable
EDITOR, if it's set, otherwise: - The string
'Notepad', if the code is running on Windows, otherwise: - The string
'vim'
Example 1: Using a temporary file
If no filename is provided, a temporary file gets edited, and its contents returned.
import editor
comments = editor.editor(text='Comments here\n\n')
# Pop up the default editor with a tempfile containing "Comments here",
# then return the contents and delete the tempfile.
Example 2: Using a named file
If a filename is provided, then that file gets edited.
import os
FILE = 'file.txt'
assert not os.path.exists(FILE)
comments = editor.editor(text=MESSAGE, filename=FILE)
# Pop up an editor for a new FILE containing MESSAGE, user edits
# This file is saved when the user exits the editor.
assert os.path.exists(FILE)
# You can edit an existing file too, and select your own editor.
comments2 = editor.editor(filename=FILE, editor='emacs -nw')
API Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file editor-1.7.0.tar.gz.
File metadata
- Download URL: editor-1.7.0.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
979b25e3f7e0386af4478e7392ecb99e6c16a42db7c4336d6b16658fa0449fb3
|
|
| MD5 |
5bd2ca1881eddba3d417b7cc24aef450
|
|
| BLAKE2b-256 |
d94f00e0b75d86bb1e6a943c08942619e3f31de54a0dce3b33b14ae3c2af2dc0
|
File details
Details for the file editor-1.7.0-py3-none-any.whl.
File metadata
- Download URL: editor-1.7.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b1ad5e99846b076b96b18f7bc39ae21952c8e20d375c3f8f98fd02cacf19367
|
|
| MD5 |
b81546217e0c5780c3be1d73c905b91e
|
|
| BLAKE2b-256 |
a6b5f566c215c58d7d2b8d39104b6cda00f31a18bb480486cb7f0d68de6131f9
|