Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

editor

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

editor

๐Ÿ–‹ Open the default text editor ๐Ÿ–‹

  • 1.6.6
  • PyPI
  • Socket score

Maintainers
1

๐Ÿ–‹ 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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc