Proper implementation of os.startfile to launch a target file/URL
Project description
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.
Usage
Simply install as a dependency of your project and then use it to launch an opener for a file or URL:
import pathlib
import shopen
shopen.open("https://zombo.com/") # Opens web browser
shopen.open(pathlib.Path("~/somefile.txt").expanduser()) # Opens file viewer
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.
There was a proposal python/cpython#47427 to
implement it as shutil.open
, but it 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.
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
Built Distribution
File details
Details for the file shopen-0.1.0.tar.gz
.
File metadata
- Download URL: shopen-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 581603aded6d84ed51c124b175a7cc0b0326db39a12d5cb5713f12f9e8eef136 |
|
MD5 | db7629fc91470ee51bf2a5d9359015b1 |
|
BLAKE2b-256 | 78e61df003bec05748a6b5cc84f0c7c002941cd7b18fa64998e57c2c8a53a1b9 |
File details
Details for the file shopen-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: shopen-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 261e0f9757f2dfc0eb5e9b198fe32b74f98899b45534fe73b3e8d06b01278712 |
|
MD5 | 4a2ddb83bc039dadf8146bf4300555b3 |
|
BLAKE2b-256 | 326f5bfdc4c4a521594bb051bd6189ca7a91cff1369a5da33cfede14cd344ea5 |