code: def open_file(filepath):
      
      if sys.platform.startswith('darwin'):
          subprocess.Popen(('open', filepath))
      elif os.name == 'nt':
          os.startfile(filepath)
      elif os.name == 'posix':
          subprocess.Popen(('xdg-open', filepath))
docs: Open file with the default system app.
      Copied from https://stackoverflow.com/a/435669/1224456