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?

9 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
>>> webbrowser.open("www.google.com")

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

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)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.