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?

Recommended Answers

All 4 Replies

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
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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.