I have a Python script named Build_all.py and in this Build_all.py I called several other scripts named First_build.py, Second_build.py, etc to run. Inside each First/Second_build.py I want to have a variable to automatically save the script name that is called. How should I do it?
In other words, how to get the name of the python script that is called - not the python file which is currently executing.
I search online and find that sys.argv[0]
and inspect.getfile(inspect.currentframe())
and __file__
. But all of these three methods give me the current executing script name (Build_all.py) not what I want (First_build.py)