UNABLE TO GET IDLE TO RUN

Terry Reedy tjreedy at udel.edu
Mon Oct 26 18:55:21 EDT 2015


On 10/26/2015 9:55 AM, Peter Otten wrote:

> The "bug" or misfeature is that idle automatically adds the working
> directory to sys.path.

I am not sure what you mean by 'working directory' here. When one runs a 
program with 'python somepath/file.py', python prepends somepath to 
sys.path.

> Ideally the editor should see the unaltered path

I don't know what you mean here.  The editor does not look as sys.path.

> while scripts started from within idle might be allowed to import from the
> working directory.

Programs run from the editor are intended to run as much as possible the 
same as if run from a command line.  To do this, IDLE must prepend 
somepath to sys.path the same as python itself does.  As a result, if 
somepath/file.py contains

import sys
print(sys.path)

then when run, sys.path  starts with os.abspath(somepath).

-- 
Terry Jan Reedy




More information about the Python-list mailing list