import os import subprocess def click_on_file(filename): '''Open document with default application in Python.''' try: os.startfile(filename) except AttributeError: subprocess.call(['open', filename])