[Python-bugs-list] [Bug #124003] sys.path[0] is not the script directory

noreply@sourceforge.net noreply@sourceforge.net
Thu, 30 Nov 2000 18:18:53 -0800


Bug #124003, was updated on 2000-Nov-30 18:10
Here is a current snapshot of the bug.

Project: Python
Category: Modules
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: Seehof
Assigned to : Nobody
Summary: sys.path[0] is not the script directory

Details: Reproduced on Windows (not tried on other systems)

The docs say:

"""The first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), path[0] is the empty string, which directs Python to search modules in the current directory first. Notice that the script directory is inserted before the entries inserted as a result of $PYTHONPATH."""

Instead, the script directory is appended to the end.

I suspect alot of existing code may be affected since this is the most convenient way to find data files that are in the same directory as a script.


Follow-Ups:

Date: 2000-Nov-30 18:18
By: gvanrossum

Comment:
I don't believe this.

I just tried this (on WIndows 98 with Python 2.0) and it correctly places the script directory at the front of sys.path.

Can you create a simple script that prints sys.path, and run this to test your hypothesis? Show us the answer.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=124003&group_id=5470