Python Forum

Full Version: a module discovering its own name
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
in a module that could be renamed when installed, is there a way for it to discover its own name at the time it is imported?
myname = __file__
__name__
yay! they both work.
__name__ is better, __file__ doesn't work in interactive mode because there is no file