I would like to be able to dynamically retrieve the current executing module or class name from within an imported module. Here is some code:
foo.py:
To get the current file module, containing folder, here is what worked for me:
import os parts = os.path.splitext(__name__) module_name = parts[len(parts) - 2]