get_module_name#

pybear.utilities.get_module_name(sys_modules_string)#

Retrieve the name of the calling module.

Parameters:
sys_modules_stringstr

Must be passed as ‘str(sys.modules[__name__])’ in the calling module.

Returns:
module_namestr

Name of the calling module.

Examples

>>> from pybear.utilities import get_module_name
>>> import sys
>>> print(sys.modules[__name__])
<module '__main__' from '...\pybear\utilities\scratch.py'>
>>> out = get_module_name(str(sys.modules[__name__]))
>>> print(out)
scratch