SectorUnkown / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

Set default directory (CWD) to that of running script #638

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open/create any script, especially one which outputs to a file without 
specifying the full path
2. Run the script
3. In the interpreter, `import os` and `print os.getcwd()`

What is the expected output? What do you see instead?
I expected that the interpreter's CWD would have been set to that of the 
script, so that files output by that script would be in the same directory as 
that script. Instead, I see that the CWD is 'C:\\Program Files\\PyScripter'.

What version of the product are you using? On what operating system?
2.5.3.0 x86 on windows 7 pro 32-bit

Original issue reported on code.google.com by pckuj...@gmail.com on 3 Apr 2012 at 5:11

GoogleCodeExporter commented 9 years ago
Is there an easy way to work around this issue and set the CWD inside the 
script without using the full path? I'm thinking something like:
import os
os.chdir(__filedir__)

Original comment by pckuj...@gmail.com on 3 Apr 2012 at 5:17

GoogleCodeExporter commented 9 years ago
Hmmm, I take it back; pyscripter *is* setting the CWD to the file. But then 
when the script finishes execution, it sets the CWD back to PyScripter's 
directory. I guess I assumed that the CWD would stay at whatever it was set to 
by the script. That way I could prototype in the interpreter and output files 
to the same dir as the script.

I still think this would be a good idea. Any input as to why I'm wrong about 
that assumption? :-)

Original comment by pckuj...@gmail.com on 3 Apr 2012 at 5:28

GoogleCodeExporter commented 9 years ago
After running a script the interpreter is brought back to the state before 
running a script.  If you want you can change the current directory of the 
interpreter back to whatever you want.

Original comment by pyscripter on 3 Apr 2012 at 6:30