[Tutor] how to open a file using os.system

Alan Gauld alan.gauld at btinternet.com
Wed Jan 9 15:04:20 CET 2008


"brindly sujith" <brindly at gmail.com> wrote

> i am developing a GUI application using TKINTER
>
> i want to open a file from the askopenfile(which is a tkFileDialog) 
> using
> OS.SYSTEM.

Your terminology is a bit confusing.

os.system(lowercase) is for executing system commands.
Do you want to execute a file as a command?
Do you  want to pass a file to a command?

In either case executing os.system requires a command
string, and the askopenfile dialog returns you a filename
as a string.

So what is the problem that you are experiencing?
Can you show us what you have tried and explain
what you want to happen.

Also be aware that os.system does not give you access
to the output of the executed command, for that
you need to use the subprocess module.

> i have already created the file open dilog using
> tkFileDialog.askopenfile(parent=root,mode='rb',title='choose a 
> file')
> Now i want to open a file from this dialog using OS.SYSTEM

You can execute a file but you cannot "open" it in any
meaningful (to Python) sense.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list