running applications in python

Jordan jordan.taylor2 at gmail.com
Thu Jan 25 13:02:29 EST 2007


os.system, os.spawn, the process module, os.popen[1,2,3,4], this is a
pretty basic thing, not trying to be mean, but you should look in the
python docs, this is definitely in there.  Also, the subprocess module
is meant to replace all of those but i haven't looked too closely at it
yet, so the following might not be perfect.

import subprocess as sp
sp.call(['wmplayer.exe', 'some_args_probably_a_movie_name'])

you'll probably need to use the full path for media player, and the
call() function is a simplified command within the subprocess module,
useful if you don't really need to redirect input/output/errors or
other aspects of the opened application.    Also, you'll probably want
something more like:  retcode = sp.call(...), so that you can check the
return code to see if it was successful.  Check out the subprocess
module.

Cheers,
Jordan

On Jan 25, 12:28 pm, "lee" <libi... at gmail.com> wrote:
> how can i run or open a windows application from the python prompt?for
> e.g.mediaplayer opening,folder acess etc




More information about the Python-list mailing list