--- os.py.orig Fri Aug 26 00:05:05 2005 +++ os.py Thu Aug 25 23:58:58 2005 @@ -208,7 +208,7 @@ __all__.extend(["makedirs", "removedirs", "renames"]) -def walk(top, topdown=True, onerror=None): +def walk(top, topdown=True, onerror=None, followlinks=False): """Directory tree generator. For each directory in the directory tree rooted at top (including top @@ -244,6 +244,10 @@ to abort the walk. Note that the filename is available as the filename attribute of the exception object. + By default os.walk does not follow symbolic links to subdirectories on + systems that support them. In order to get this functionality, set the + optional arg 'followlinks' to true. + Caution: if you pass a relative pathname for top, don't change the current working directory between resumptions of walk. walk never changes the current directory, and assumes that the client doesn't @@ -287,8 +291,8 @@ yield top, dirs, nondirs for name in dirs: path = join(top, name) - if not islink(path): - for x in walk(path, topdown, onerror): + if followlinks or not islink(path): + for x in walk(path, topdown, onerror, followlinks): yield x if not topdown: yield top, dirs, nondirs