On 16 Mai, 11:04, Steven D'Aprano <steve +comp.lang.pyt...@pearwood.info> wrote: > Python does use your current working directory as your current working > directory. I think you are misdiagnosing the problem.
That's usually how it ends up ... > > Here's a demonstration: > > steve@runes:~$ cat test.py > import os > print os.getcwd() > > steve@runes:~$ ln -s ~/test.py /tmp/test > steve@runes:~$ ls -l /tmp/test > lrwxrwxrwx 1 steve steve 19 May 16 18:58 /tmp/test -> /home/steve/test.py > steve@runes:~$ cd /etc/ > steve@runes:/etc$ python /tmp/test > /etc You're right. I can believe that python doesn't really change it's notion of the CWD. It seems like when I'm in WC and invoke ./script (which is symlinked to H/script), python says, "I have a specification somewhere that says I can look for modules where my script is, and since I'm really smart, I happen to know that I'm in WC but the script is not, but is really in H, where the stupid operator better have his packages set up" > > > I have a python script that works fine when it sits in directory WC, but > > if I move it out of WC to H and put a symlink from H/script to WC, it > > doesn't find the packages that are in WC. Also, if I use the absolute > > path to H, it won't find them, but I guess I can understand that. > > The obvious solution is to make sure that WC is in the Python path. ... > but that's a crappy solution, Right. Other tools don't try to figure out what I really want to do with a symlink, but just accept that it's a file. Python should do the same ... But, as you say, I'm surely misdiagnosing the problem. -- http://mail.python.org/mailman/listinfo/python-list