hi everyone. to put it plainly, I was writing some python code that used the itunes scripting interface to control itunes. so I got all of my functions down, and now I wanted to have these actions occur on a specific mouse press. thanks to Tech B, I used the pyhook library to cover all of that. For whatever stupid reason, the itunes scripting interface won't let you call it's functions if it is receiving some type of hardware input :( (whats the point of that?? if you want to see the specific error, just request it and i'll post it) anyways... I wrote a simple little server and client running on localhost that takes the mouse input, and sends it to the server. the server then takes the data it has received (string variable called data), and calls one of the specific functions I wrote that calls a specific itunes scripting function. So I figure out how to call functions from dictionarys:

def a():print 'this is a'
def b(): print 'this is b'
funcs = { 'a':a, 'b':b }
funcs['a']()

...but the only problem I ran into was how to call functions with arguements. so I would like something like this:

data = 'volume(50)'
magical_function_caller_function( data )

the exec function hasn't really been that helpful.. So if any of you would happen to know how to call functions (with arguements) from strings, feel free to post a reply. Thanks!

ya that worked awesome. thanks!; this was a really needed part for my program :)

This article has been dead for over six months. Start a new discussion instead.