You are right, but my concern is not the relative path resolution. Let me clarify:

/home/jeanmichel/test.py:
"import sys
print sys.path"

>python.exe test.py
sys.path = ['/home/jeanmichel']
> from within a python shell:
sys.path = ['']

The unpredictable effect of '' (at least something I did not predict) is that it allows absolute path resolution, while '/home/jeanmichel' cannot.
Example :
write a anotherTest.py file:
"
__import__('/home/jeanmichel/test')
"

anotherTest.py will be successfully imported in a python shell ('' + '/home/jeanmichel/test.py' is a valid path), but the "python.exe anotherTest2.py" form will fail as it will try for '/home/jeanmichel' +'/home/jeanmichel/test.py' which is not a valid path.

So my question is: "why the shell is adding '' when the interpreter is adding the full path ?"

Hope I'm not too foggy.

JM

Aahz wrote:
In article <mailman.406.1242754524.8015.python-l...@python.org>,
Jean-Michel Pichavant  <jeanmic...@sequans.com> wrote:
I spent quite a time on a malicious issue. I found out that there is a
slight difference on the sys.path content when either executing code
>from a shell or from within a script.  This difference is the '' item,
which is present in the shell form of sys.path.

Why are you calling this a malicious issue?

When I do this test, I find that the current working directory's full
path is prepended to sys.path, so if you're having problems, I bet that
you're changing your working directory during program execution.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to