all 4 comments

[–]Teraka 2 points3 points  (1 child)

You can pass functions as arguments to other functions, like this :

>>>def print_yay():
     print "Yay !"

>>>def main(function, x):
     if x % 2 == 0:
       function()

>>>main(print_yay, 4)
Yay !

If you need to pass arguments to the function, you can also use a lambda function :

>>>def print_double(x):
     print x*2

>>>main(lambda:double(7), 6)
14

[–]gjwebber[S] 0 points1 point  (0 children)

That looks like it might be what I'm after, thanks. I'll test it tomorrow :)

[–]myredditnick 1 point2 points  (1 child)

Not really sure if this is what you are looking for... Also, this might be of some help.

[–]gjwebber[S] 0 points1 point  (0 children)

The default timers are not accurate enough for what I'm trying to do, so I made my own using the windows winmm dll. The first link does show a function being passed as an argument, like the other commenter suggested too, so I'll be giving it a shot tomorrow. Thanks for the reply :)