Skip to main content

shopen

shopen is a proper implementation of os.startfile to launch a target file/URL. Use it to launch the preferred system viewer for the user to view or edit a target file or URL.

"shopen" is short for shutil.open, the proposed builtin it's intended to be a reference implementation for.

PyPI - Version PyPI - Python Version


Usage

Simply install as a dependency of your project and then use it to launch an opener for a file or URL:

import pathlib, shopen
shopen.open("https://zombo.com/")  # Opens web browser
shopen.open(pathlib.Path("~/somefile.txt").expanduser())  # Opens file viewer
shopen.open(pathlib.Path("./somefile.toml"), "edit")  # Opens editor

Why?

Python's standard library provides nice cross-platform utilites for lots of different purposes, but so far no simple file/URL opener that would work on all platforms.

On Windows there's os.startfile, but strangely that doesn't support any other platform.

The proposal python/cpython#47427 to implement it as shutil.open was rejected for now. Python users keep asking for a decent way to do it, but the only answer had been brittle copypasta… until now!

Ideally this can be added into stdlib after proving its usefulness and then only be needed as a polyfill for older versions of python.

Metadata

Release files for shopen 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shopen 0.2.2
File Size Uploaded
shopen-0.2.2.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shopen 0.2.2
File Interpreter ABI Platform
shopen-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / shopen-0.2.2.tar.gz

Download URL shopen-0.2.2.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6e702c57616768856a86cf39cb780470196b6d96a20caa2b2703ae0334235edd
BLAKE2b-256 checksum
How to use checksums
3d6e3bd9e1d801fce365962f3c9c71eed6154d9d97c7f73946cbce4371d2faff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / shopen-0.2.2-py3-none-any.whl

Download URL shopen-0.2.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d584291c76e64bda7f04ea168afb3314c2bfe194b5098f863d735753550ab373
BLAKE2b-256 checksum
How to use checksums
01fd634b8d5a76af735988e28462d71056abb3e5087233b1166b453f2b522d81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page