calling_module

privex.helpers.black_magic.calling_module(skip=2) → Optional[str][source]

Returns the name of the module which called your function/method.

Parameters

skip (int) – Skip this many frames. 0 = module containing calling_function() 1 = module which called calling_function() 2 = module which called the function that called calling_function() (default) and so on…

Return str|None mod_name

Either a string containing the module name, or None if you’ve skipped too many frames. If called from the main python script, then '__main__' will be returned instead of a proper module path.