How can one get the fully qualified name of a module in Python, at the module level?
For example, let's say this is the file structure:
foo
├── setup.py
└── bar
└── baz
└── spam.py
From within the spam.py
file at the module level, how can I get the fully qualified module name "bar.baz.spam"
?
There is __file__
, which one can pair with inspect.getmodulename(__file__)
to get the module name "spam"
. However, how can I turn this into "bar.baz.spam"
?