How can I know the name of "caller"

Jay Loden jloden at jayloden.com
Tue Jun 19 17:58:14 EDT 2007


billiejoex wrote:
> Hi there,
> unfortunately, I'm compelled to apply a sort of monkey patching at the
> code of an existing libreary that I can't modify directly.
> Here's my question
> Having such code:
> 
> class test:
> 
>     def caller(self):
>         self.b()
> 
>     def called(self):
>         pass
> 
> ...(if it is possible) how can I get, from method "called", the name
> of function/method that called it (in this case "caller")?
> 
> Thanks in advance
>

I asked a similar/related question recently, it might put you on the right track also:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/723d4ce3e6703a26/ce2bb076ec4a8059?lnk=st&q=&rnum=2#ce2bb076ec4a8059

-Jay



More information about the Python-list mailing list