[Tutor] A simple question
SA
sarmstrong13@mac.com
Tue, 13 Aug 2002 10:52:20 -0500
On 8/13/02 2:46 AM, "Thomi Richards" <thomi@thomi.imail.net.nz> wrote:
I may be wrong on this. But it seems like when I was reading "Learning
Python", there was a section on setting up python with a shell script. And I
remember one of the directories it said Python looks into is '.'. So I ran
this quick script:
Import sys
for i in range(len(sys.path):
sys.path[I]
I got the correct libraries where python modules are stored, including ''.
So I'm thinking and I can be wrong here, '' is left empty so that Python can
load the current directory dynamically. Of course, I'm probably way off base
here.
Anyone else?
Thanks.
SA
--
"I can do everything on my Mac I used to on my PC. Plus a lot more ..."
-Me
>
>
> well, when python looks for modules to import, it scans through all the
> directories in the sys.path string.... more than that i cannot tell
> you...
>
> :-)
>
> On Tue, 13 Aug 2002 09:33:53 +0200 (MEST) Thus said lumbricus@gmx.net:
>
>> Hi!
>>
>>> this is the way i do it:
>>>
>>> -----<SNIP>------
>>> #!/usr/bin/python
>>>
>>> #above line needed in unix like environs only!
>>>
>>> import sys
>>>
>>> sys.path[0] = '/home/thomi/custom_python_modules/'
>>>
>>> #set the above path to the dir where all my custom modules are
>>>
>>> import thomimodule1
>>>
>>> ------<SNIP>-----
>>>
>>> this does work, ive tried it myself before... sys.path[0] is free,
>>> and
>>
>> Yes:
>>>>> sys.path[0]
>> ''
>>>>>
>> But _why_?
>> Has anybody an explanation?
>>
>>> can be used safely, otherwise you'd have to go:
>>>
>>> sys.path.append('/home/thomi/custom_python_modules')
>>>
>>> hope that helps..
>>
>> [ TOFU snipped ]
>>
>> puzzled greetings,
>> J"o!
>>
>> --
>>
>> --
>> GMX - Die Kommunikationsplattform im Internet.
>> http://www.gmx.net
>>
>>
>> _______________________________________________
>> Tutor maillist - Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>