def open_file(filename):
    """
    Multi-platform way to make the OS open a file with its default application
    """
    if sys.platform.startswith("darwin"):
        subprocess.call(("open", filename))
    elif sys.platform == "cygwin":
        subprocess.call(("cygstart", filename))
    elif os.name == "nt":
        os.system("start %s" % filename)
    elif os.name == "posix":
        subprocess.call(("xdg-open", filename))
Multi-platform way to make the OS open a file with its default application