Current Working Directory

868 views
Skip to first unread message

Titusz

unread,
Mar 24, 2009, 1:53:30 PM3/24/09
to PyScripter
Hi there,

i am a python beginner and found pyscripter to be fun to work with...
maybe someone here can help me out with a simple problem:

is there an easy way to automatically set the current working
directory of PyScripters interactive python interpreter (Internal or
Remote engine) to the path of the last run script?

for simplicity i currently don´t use pycripter projects or run
configurations. would i need to use those to accomplish this?

regards
titusz

PyScripter

unread,
Mar 24, 2009, 9:11:37 PM3/24/09
to PyScripter
By default the working directory is set to the directory of the script
you run. You can setup an alternative working directory by using a
Run Configuration in the Project Explorer.

Titusz

unread,
Mar 25, 2009, 6:14:08 AM3/25/09
to PyScripter
i tested with pycripter v 1.9.9.6 on two different machines (both
vista). here is what exactly happens:

i start up pyscripter. an os.getcwd() executed in the internal
interactive interpreter shows me: 'C:\\Windows\\system32'

i write a script with this content:
import os
print is.getcwd()

and save it at C:\Users\Username\code\cwd.py
now i run it from within pyscripter (F9)

the scripts output is fine. it says C:\Users\Username\code
but another os.getcwd() in the integrated interactive python shell
still gives me: 'C:\\Windows\\system32'

it would be convenient to have it autoswichted to the cwd of the last
run script...
(my system32 folder is full with .pickle files by now ;.)

regards
titusz

PyScripter

unread,
Mar 25, 2009, 3:40:10 PM3/25/09
to PyScripter
The working directory is restored at the end of running a script. To
change it permanently change it from the interactive interpreter.
Reply all
Reply to author
Forward
0 new messages