sys.path[0] in IDLE

Lee Harr missive at frontiernet.net
Sun Dec 28 08:13:15 EST 2003


On 2003-12-27, Gabriel Genellina <gagenellina at softlab.com.ar> wrote:
> At 26/12/2003 22:25, you wrote:
>
>>Am I reading this correctly?
>>
>>http://python.org/doc/current/lib/module-sys.html
>>
>>"""
>>As initialized upon program startup, the first item of this list,
>>path[0], is the directory containing the script that was used to
>>invoke the Python interpreter.
>>"""
>>
>>
>>So, sys.path[0] should be the directory that my script is in?
>>
>>Even if running the script from IDLE?
>>
>>Has anyone else had problems with this? Especially on windows?
>
> (Read the remaining of the paragraph too)
> When using IDLE, the "script" is really idle.py. If you start IDLE with 
> another script as an argument, its dir is prepended in sys.path
>
>


So, are you saying you do not see your script as sys.path[0] also?

That seems like a bug to me.

It works fine for me on FreeBSD 4.9 with python 2.3, so it can't be
that IDLE needs to have its own directories in the path before mine.

What do others get saving this script in IDLE and running it?



# /usr/home/lee/python/idle_test/foo/bar.py
import sys
print sys.path





IDLE 1.0.2      
>>> import sys
>>> print sys.path
['/usr/home/lee', '/usr/local/bin', '/usr/local/lib/python23.zip', ...]
>>> # now open /usr/home/lee/python/idle_test/foo/bar.py and run the script
>>> ================================ RESTART ================================
>>> 
['/usr/home/lee/python/idle_test/foo', '/usr/home/lee', '/usr/local/bin', ...]
>>> 





More information about the Python-list mailing list