Skip to main content

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.

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
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

shopen-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

shopen-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

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

Hashes for shopen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 581603aded6d84ed51c124b175a7cc0b0326db39a12d5cb5713f12f9e8eef136
MD5 db7629fc91470ee51bf2a5d9359015b1
BLAKE2b-256 78e61df003bec05748a6b5cc84f0c7c002941cd7b18fa64998e57c2c8a53a1b9

See more details on using hashes here.

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

Hashes for shopen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 261e0f9757f2dfc0eb5e9b198fe32b74f98899b45534fe73b3e8d06b01278712
MD5 4a2ddb83bc039dadf8146bf4300555b3
BLAKE2b-256 326f5bfdc4c4a521594bb051bd6189ca7a91cff1369a5da33cfede14cd344ea5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page