[Tutor] How do I open my browser from within a Python program
Simon Brunning
simon at brunningonline.net
Thu Sep 14 12:33:13 CEST 2006
On 9/14/06, nimrodx <nimrodx at slingshot.co.nz> wrote:
> Basically a dumb question I can't seem to find the answer to.
>
> How do I execute a bash command from within a python program.
Well, this question doesn't match the subject line. So, *two* answers.
To open a web browser from within a python program, you want something like:
import webbrowser
webbrowser.open('www.google.com')
To run a shell command - well, it depends. If you don't care about
reading the output or so on, you can just do:
import os
os.system('ls')
If you want to access the input and/or output streams, or to wait for
the shell command to finish, or anything even remotely complex, look
at the subprocess module.
--
Cheers,
Simon B,
simon at brunningonline.net
More information about the Tutor
mailing list