I've learned quite a bit since my last post, i.e. it kept disappearing on me just because of syntax, but now I'm interested in something:

Is it possible to make it so that when you run the .py as is , that it opens another program or directory? I.e. when you run it, it opens internet explorer? or another python script?

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by max.yevs

what i'm really asking is is there any way to get a program to open something in a new window from a command?

Yeah you can do open internet things with the webbrowser module.
Oh and also execfile is good if you want to start executables or python files.

``````>>> import webbrowser

And execfile

``````#its a built in!
execfile("Path \\ to\\ exe or py \\ file.exe")``````

Hope that helps

If you want to run something arbitrary:

``````import os
os.system('your\path\here')``````

Using the webbrowser module would make more sense for that specific problem, as said above.

wow thanks, those all work great!

what i was really thinking of was just to make a program that opens the same program in a new window and kind of 'short circuits'

i did end up doing it, but instead of a program simply a command in command prompt (see it here if you want, but its not very interesting)