catch a function call

This is the place for queries that don't fit in any of the other categories.

catch a function call

Postby 3t3r4n » Mon Aug 12, 2013 5:18 pm

How can i catch a function call?

game.py
Code: Select all
...
class GameWindow():
...
   def OnKeyUp(self, key):
      ....

test.py
Code: Select all
import game
...
   def bypass(self,key):
      do something


When OnKeyUp is called i want to automaticaly call bypass function without modify game.py ... how can i do this? Something like detours in C++
I've donne this last year but i don't know how :( i don't remember ... it was a function to connect this 2 functions
3t3r4n
 
Posts: 1
Joined: Mon Aug 12, 2013 5:07 pm

Re: catch a function call

Postby micseydel » Mon Aug 12, 2013 7:56 pm

I don't think you can do what you're describing, but you could get that behavior by inheriting from GameWindow, overriding the OnKeyUp method to have it call your desired function and then call the superclass' one.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1270
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 5 guests

cron