This is a cross-platform version of the os.startfile function in the Python standard library.
It emulates the following actions in an operating system's UI:
- double-clicking a file
- single-clicking a URL
which will open the default program associated with that type.
- Python 3.7+
Install it directly into an activated virtual environment:
$ pip install universal-startfile
or add it to your Poetry project:
$ poetry add universal-startfile
After installation, import the startfile
function:
from startfile import startfile
startfile("~/Downloads/example.png")
startfile("http://example.com")