How do you execute an OS X application (bundle) from Python?
Alex Martelli
aleaxit at yahoo.com
Thu Nov 4 09:36:48 EST 2004
David Hughes <dfh at forestfield.co.uk> wrote:
> For example, in Python in a Nutshell, Alex Martelli shows how you can
> run a Windows (notepad.exe) or Unix-like (/bin/vim) text editor using
> os.spawnv(os.P_WAIT, editor, [textfile])
> But how would you call the OS X text editor /Applications/TextEdit.app
> - which appears to be a whole directory inside /Applications?
>
> I'm sorry if the answer is blindingly obvious. I work alone and
> sometimes just get stuck, then have to ask in public and risk
> appearing a noodle brain.
You could spawn the 'open' command (/usr/bin/open) which you also use to
open all kinds of files from OSX's Terminal. Unfortunately, the P_WAIT
doesn't work in the intended way in this case -- it doesn't wait for the
application to be closed (so that the user has finished editing the
file), but rather it gives you control at once.
Unfortunately, I don't know how to get the P_WAIT functionality on OSX
for a .app directory/bundle -- you may want to ask on the pythonmac-sig!
Alex
More information about the Python-list
mailing list