[Tutor] Who called me?

Kent Johnson kent37 at tds.net
Tue Nov 8 20:46:07 CET 2005


Bill Campbell wrote:
> Is there a way in python for a method to determine its parent?
> 
> In particular, I'm working with SimpleXMLRPCServer, and would
> like to be able to find the client_address in the routine that
> has been dispatched.  I know that client_address is an attribute
> of the handler class instance, but don't know how to get to that.

You can inspect the stack frame to find this out. Search the online cookbook for _getframe - I don't see one recipe that does exactly what you want but the pieces are there.
http://aspn.activestate.com/ASPN/Cookbook/Python

Kent

-- 
http://www.kentsjohnson.com



More information about the Tutor mailing list