0

Possible Duplicate:
Open document with default application in Python

I want python code to launch a file with its default application

e.g. a .txt file with notepad(when notepad is set as the default application to open .txt files) I want to do this for WIN 32 bit, WIN 64 bit and MAC OS X

Please help me out

Community
  • 1
  • 1
Pankaj Vatsa
  • 2,599
  • 5
  • 24
  • 28

2 Answers2

0

Well it might seem awkward but following works quite well under Win Xp:

import webbrowser

webbrowser.open("myFile.txt")
Jeannot
  • 1,165
  • 7
  • 18
  • 1
    From the docs: "Note that on some platforms, trying to open a filename using this function, may work and start the operating system’s associated program. However, this is neither supported nor portable." So +0: I don't think this is quite right, but I don't know what the best solution is. – Thomas K Nov 17 '11 at 12:56
0

I don't know about OS X, but an os.system call with the file name as an argument works on Windows.

Also take a look at this answer.

Community
  • 1
  • 1
martineau
  • 119,623
  • 25
  • 170
  • 301