If I understand correctly, When typing sys.argv[0] it shows the name of the .py file one is working on. But when I do this, it shows me a different name:
sys.argv[0]
'C:\\Anaconda\\lib\\site-packages\\spyderlib\\widgets\\externalshell\\start_ipython_kernel.py'
The real name of the file is 'Ra x 13 arima.py' and its located in 'C:\Users\infantjo\Documents\Python Scripts\Projects\Work in Progress'
The current directory is:
os.getcwd()
'C:\\Users\\infantjo\\Documents\\Python Scripts\\Projects'
What am I doing wrong?
(Im using Python 2.7.11 in Spyder 2.3.8 installed with Anaconda 2.3.0, 64bit).
argv contain a list of command line arguments passed to python script. argv[0] is the script name. doc
IDE like Spyder / PyCharm doesn't run the script direct. It's run the wrapper that run Your script.
In this case Spyder run the start_ipython_kernel.py script that get a Your script name as a parameter and run it.
If You need a script name use a __file__ var.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With