I'll pay $40 in e-gold if you'll fix this bug.

Jan Walter jan at q-bus.de
Tue Jun 8 06:59:35 EDT 1999


Hi,

Maybe you get confused a bit by the bash!!!

Try following:
bash$ tcsh
tcsh: cd /tmp/
tcsh: mkdir dirOne
tcsh: mkdir dirTwo
tcsh: mkdir dirTwo/dirThree
tcsh: ln -s dirTwo/dirThree/ .
tcsh: cd dirThree/
tcsh: pwd
/tmp/dirTwo/dirThree

Do the same with the bash (removing the directories of course):
bash$ cd /tmp/
bash$ mkdir dirOne
bash$ mkdir dirTwo
bash$ mkdir dirTwo/dirThree
bash$ ln -s dirTwo/dirThree/ .
bash$ cd dirThree/
bash$ pwd
/tmp/dirThree

The tcsh gives the right answer. You are in the /tmp/dirTwo/dirThree directory. If you try
to move a file with "mv file.txt ../dirOne/file.txt" you can´t do that because there is no
directory dirOne !!!

Python works like tcsh. If you try the following you get the right answer:
bash$ cd /tmp/dirThree/
bash$ python
Python 1.5.1 (#1, May  6 1998, 01:48:27)  [GCC 2.7.2.3] on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> os.getcwd()
'/tmp/dirTwo/dirThree'

My suggestion:

You can test if there are symbolic links in your path (e.g. os.path.islink("/tmp/dirThree")
within Python) or you can prove that /tmp/dirThree is in reality /tmp/dirTwo/dirThree and
life with that fact ...

Cheers,

Jan







More information about the Python-list mailing list