Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Open given file with the default application. Works on Linux, OS X and Windows. On Linux requires xdg-open (usually built-in).
import sys
import subprocess
import os
import platform
def open_with_default(path):
current_platform = platform.system()
if current_platform == "Linux":["xdg-open", path])
elif current_platform == "Windows":
os.system("start "+path)
elif current_platform == "Darwin":["open", path])
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.