Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: sys.path[0] in IDLE

Reply
Thread Tools

Re: sys.path[0] in IDLE

 
 
Gabriel Genellina
Guest
Posts: n/a
 
      12-27-2003
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


Gabriel Genellina
Softlab SRL


 
Reply With Quote
 
 
 
 
Lee Harr
Guest
Posts: n/a
 
      12-28-2003
On 2003-12-27, Gabriel Genellina <(E-Mail Removed)> 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', ...]
>>>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
804 Packet loss during dialer idle timeout process? Loren Amelang Cisco 3 02-07-2005 10:59 PM
Do routers normally drop connections after idle periods? Bartt Wireless Networking 6 12-12-2004 03:35 AM
PIX Idle connection timeout Rob Cisco 1 11-17-2004 11:20 PM
dialer idle-timout doesn't get reset Dennis Ortsen Cisco 4 08-03-2004 02:42 PM
Session-Timeouts and Idle-Timeouts on AS5300 and AS5800 Matt Cisco 1 02-17-2004 06:59 PM



Advertisments