Q:

How to display file on the screen in python?

How to display file on the screen in python ?
Note:
I don't want to open for read or write, i want to display the file on the screen,
like i double click on the file himself and it's open .
Thank you.

A:

Well in windows only executing the file works:
import os
os.system('c:/tmp/sample.txt')

on SO based in UNIX there is an enviroment variable named EDITOR and you can do something like this:
import os
import subprocess
try:
    subprocess.call([os.environ['EDITOR'], 'filename'])
except:
    try:
        subprocess.call(['gedit', 'filename'])
    except:
        subprocess.call(['nano', 'filename'])

