confusion regarding os.path.walk()
sholden at holdenweb.com
Wed Feb 20 08:19:49 EST 2002
"Andrew Brown" <killspam at darwinwars.com> wrote in message
news:Xns91BB770F47AD4andrewdarwinwarscom at 184.108.40.206...
> 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
> Thanks for your help, and I hope this sometime helps a passing googler.
> Other people will surely fall into the same pit.
They surely will, and you've done a useful piece of learning (as well as
helping future Googlers). Next time, remind yourself: "There's a reason why
symbolic links are called symbolic"!
The path is, as you have discovered, generated by appending strings, not by
traversing the filestore tree.
Consulting, training, speaking: http://www.holdenweb.com/
Author, Python Web Programming: http://pydish.holdenweb.com/pwp/
"This is Python. We don't care much about theory, except where it
intersects with useful practice." Aahz Maruch on c.l.py
More information about the Python-list