I want my program to open iTunes during runtime. How do I implement this ?
I looked around for answers but didn't get any concrete complete answers. Till now, all I know is I could use the os
module and then call the os.system()
function to open iTunes. If this is right, what goes into the brackets ?
I have a Mac OS X machine.
Asked
Active
Viewed 325 times
0

Shonu93
- 846
- 1
- 10
- 19
-
Which operating system? They each different `api's` and methods of doing such tasks. – Aug 30 '13 at 15:13
-
@enginefree Hey buddy ! It's a Mac OS X – Shonu93 Aug 30 '13 at 15:39
-
Take a look at `macpython` and this link http://wiki.python.org/moin/MacPython/AppleScript – Aug 30 '13 at 15:47
4 Answers
0
Use subprocess.call()
if you want to simply run an executable.
os.system()
run the command in a subshell, which generates an unnecessary extra process and slightly different behavior depending on the operating system/console used (for example cmd.exe
have different escaping than bash
)

KurzedMetal
- 12,540
- 6
- 39
- 65
0
One straightforward way to do this on Mac OS X will be to use the open
command:
os.system("open -a iTunes")
There are undoubtedly other ways of doing this (e.g, using the Cocoa/Python bridge), but this is the simplest.
-
Hey thanks ! Worked like a charm. What would I need to input if I want to enter a particular song (say x.mp3) through iTunes ? – Shonu93 Aug 30 '13 at 16:39
0
Read subprocess
, is better than os.system
in your case.
Subprocess module: http://docs.python.org/2/library/subprocess.html

Black_Ram
- 343
- 5
- 9
- 19