How to get the name of the top most (entry) script in python? -
i have utility module in python needs know name of application being used in. means name of top-level python script invoked start application (i.e. 1 __name=="__main__" true). __name__ gives me name of current python file, how name of top-most 1 in call chain?
having switch google query "how to find process name python" vs how find "top level script name", found this overly thorough treatment of topic. summary of following:
import __main__ import os appname = os.path.basename(__main__.__file__).strip(".py")
Comments
Post a Comment