os.path.walk and symbolic links

François Pinard pinard at iro.umontreal.ca
Thu Aug 24 11:55:57 EDT 2000


Hi, people.

By any chance, is there a known, or easy idiom so `os.path.walk' would
follow symbolic links to directories (a bit like `find -follow')?

If no, I could probably easily simulate it by having the walker function
to call itself with symbolic link definitions, but then, I would have
another little problem, as `os.path.join' does not simplify the result
when its second argument is relative (yet it does the proper thing when
the second argument is absolute).  For example, with 1.5.2 on Linux:

>>> os.path.join('/abc/def/ghi', '../xyz')
'/abc/def/ghi/../xyz'

while I would like to get:

'/abc/def/xyz'

I'll manage, of course, yet I wonder if `os.path.join' could not be amended
a bit to act more cleverly in some later Python release.  Is it reasonable?

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list