Hello stackoverflow community,
How can I get the script name when using execfile() in IPython to run the script?
Demonstration:
I've created this script (named printScriptName.py
)
import os,sys
print os.path.basename(sys.argv[0])
This is the output when running it using IPython:
In [37]: execfile('printScriptName.py')
ipython-script.py
Which is obviously not printScriptName.py
.
Thanks.