I\'ve searched and this seems to be a simple question without a simple answer.
I have the file a/b/c.py which would be called with python -m a.b.c
a/b/c.py
python -m a.b.c
Why does nobody mentioned the .__module__?
.__module__
When doing a self.__module__ you will get the module path. You can also do this outside of the class:
self.__module__
Class A: self.__module__ # gets module.filename def get_module(): A.__module__ # also gets module.filename