confusion regarding os.path.walk()
Andrew Brown
killspam at darwinwars.com
Wed Feb 20 06:41:33 EST 2002
rmunn at pobox.com (Robin Munn) wrote in
news:slrna75bg5.hg.rmunn at rmunn.dyndns.org:
> assuming
> burrows.html is the "real" file and Burrows.htm is the symlink you
> want to create, then the command you really want to be running is:
>
> ln -s burrows.html ./wombats/habitat/Burrows.htm
>
> This will create the symlink Burrows.htm -> burrows.html in the
> directory wombats/habitat. If you did:
>
> ln -s ./wombats/habitat/burrows.html ./wombats/habitat/Burrows.htm
>
> then what you would get would be: in the directory wombats/habitat,
> there would be a symlink named Burrows.htm that tried to reference
> wombats/habitat/wombats/habitat/burrows.html -- this is almost
> certainly not what you wanted.
>
Yes. This is exactly the gotcha that got me. It's not at all obvious, and
it's not really a python problem either. It seems to arise from the way
that Unix makes symlinks: I had assumed that it first looks for the file
to link to, and then makes the link file. But it turns out to be the
other way around. So, though I had tried all sorts of path manipulations
to ensure that the link was found relative to the file linked to, I never
tried chopping the path of the target file, which would have solved my
problem.
Thanks for your help, and I hope this sometime helps a passing googler.
Other people will surely fall into the same pit.
More information about the Python-list
mailing list