[Idle-dev] [ idlefork-Bugs-745525 ] Current Working Directory

SourceForge.net noreply@sourceforge.net
Thu, 29 May 2003 13:19:01 -0700


Bugs item #745525, was opened at 2003-05-29 09:27
Message generated for change (Comment added) made by kbk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109579&aid=745525&group_id=9579

Category: None
Group: None
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Bruce Sherwood (bsherwood)
>Assigned to: Kurt B. Kaiser (kbk)
>Summary: Current Working Directory

Initial Comment:
I'm not sure whether this is a bug or a feature, but it
represents a significant change from the original idlefork.

Put this at the start of a file and run it:
import os
print os.getcwd()

In the past this was the directory where the file is
saved, but now it is always the starting directory for
IDLE (on Windows, the directory specified in the "Start
in:" property of the shortcut used to start IDLE),
independent of where the file is stored. This makes it
awkward to test and run programs that do simple file
I/O in the program's own directory, where in the past
it was sufficient just to do an open on the data file.

----------------------------------------------------------------------

>Comment By: Kurt B. Kaiser (kbk)
Date: 2003-05-29 15:19

Message:
Logged In: YES 
user_id=149084

Currently it's working the same way as Python IDLE
but different from VPython IDLE.  There are three
possibilities:

1. Only change directory when the user issues a
change directory command.  This is what Unix people
expect, and this is what Python IDLE does. The 
working directory is the one where you started
IDLE.

2. Change directory when opening a file.  This seems
to be what Windows does.  Your working directory
is that of the last file you opened.  This has 
advantages because it's *really* hard to change
directory on Windows otherwise if you are not using a 
Command window.  You have to set .py to associate
with IDLE and fiddle with Folder Options / File
Types / Advanced, I think, and then diddle the
PATH environment variable.  

3. Change directory when running a program; change
to the directory of the program.  This is what 
VPython IDLE does via Remote.py. This has the 
disadvantage that if you happen to be calling a script
from another directory, you will be abruptly and 
surprisingly chdir'd to, say, python22/lib/site-packages/
scripts.

I think adhering to the principle of least surprise is
the right thing to do, but in this case the amount
of surprise depends on which platform you are used
to.  Now, if you were using pure Python you would
not expect a cd to the directory of the script!!

When I fixed Bug  706860 I noted that the submitter
was not sure whether a chdir was warranted, and
he's a Windows man.  But at least we now have the
script's directory on sys.path.

To me, the aggravation comes as follows:  I open
IDLEfork, then open a file in my working directory 
under My Documents.  Then I start a new file to
continue the project, go to save it, and IDLEfork
wants to save it to the "start in" directory.  This
is closely related to your complaint, and we may
be able to handle both with the same solution.

My preference would be #2 above.  Change
directory every time a file is opened with the
file open browser.

But don't change directory if IDLE is fed a script
from the command line.

I wonder what other people think about this?


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109579&aid=745525&group_id=9579