Lauch default editor (like 'webbrowser' module)
The modern Linux way to open a file is using xdg-open
; however it does not guarantee that a text editor will open the file. Using $EDITOR
is appropriate if your program is command-line oriented (and your users).
Under windows you can simply "execute" the file and the default action will be taken:
os.system('c:/tmp/sample.txt')
For this example a default editor will spawn. Under UNIX there is an environment variable called EDITOR
, so you need to use something like:
os.system('%s %s' % (os.getenv('EDITOR'), filename))