def getCallerInfo(depth=2):
 f = sys._getframe(depth)
 method_name = f.f_code.co_name
 filename = f.f_code.co_filename
 arg_class = None
 args = inspect.getargvalues(f)
 if (len(args[0]) > 0):
  arg_name = args[0][0]
  arg_class = args[3][arg_name].__class__.__name__
 return (method_name, filename, arg_class)

def getCallerInfo ( depth = 2 ) : f = sys . _getframe ( depth ) method_name = f . f_code . co_name filename = f . f_code . co_filename arg_class = None args = inspect . getargvalues ( f ) if ( len ( args [ 0 ] ) > 0 ) : arg_name = args [ 0 ] [ 0 ] arg_class = args [ 3 ] [ arg_name ] . __class__ . __name__ return ( method_name , filename , arg_class )
utility function to get information about function callers the information is the tuple the class will be none if the caller is just a function and not an object method .