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
I think you're actually looking for the __name__
special variable. From the Python documentation:
Within a module, the module’s name (as a string) is available as the value of the global variable
__name__
.
If you run a file directly, this name will __main__
. However, if you're in a module (as in the case where you're using the -m flag, or any other import), it will be the complete name of the module.