def calledby(callerdepth=1):
 import inspect, os
 stack = inspect.stack()
 callerdepth = min(max(2, (callerdepth + 1)), (len(stack) - 1))
 frame = inspect.stack()[callerdepth]
 path = os.path.sep.join(frame[1].rsplit(os.path.sep, 2)[(-2):])
 return ("[called by '%s': %s:%s %s]" % (frame[3], path, frame[2], frame[4]))

def calledby ( callerdepth = 1 ) : import inspect , os stack = inspect . stack ( ) callerdepth = min ( max ( 2 , ( callerdepth + 1 ) ) , ( len ( stack ) - 1 ) ) frame = inspect . stack ( ) [ callerdepth ] path = os . path . sep . join ( frame [ 1 ] . rsplit ( os . path . sep , 2 ) [ ( - 2 ) : ] ) return ( "[called by '%s': %s:%s %s]" % ( frame [ 3 ] , path , frame [ 2 ] , frame [ 4 ] ) )
only to be used for debug purposes .