diff options
author | Georg Brandl <georg@python.org> | 2007-03-21 09:10:29 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-03-21 09:10:29 +0000 |
commit | cae9f3d91609635374956e9ad71109bf1e90fa58 (patch) | |
tree | f49288c8da9c6356f2d84275222e3c50a904cdac /Doc/lib/libos.tex | |
parent | 5cb76c19ba5b22b926f69d017a79eb2de296785a (diff) | |
download | cpython-git-cae9f3d91609635374956e9ad71109bf1e90fa58.tar.gz |
New test for rev. 54407 which only uses directories under TESTFN.
Diffstat (limited to 'Doc/lib/libos.tex')
-rw-r--r-- | Doc/lib/libos.tex | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex index 1a39693b80..638ed6b6ed 100644 --- a/Doc/lib/libos.tex +++ b/Doc/lib/libos.tex @@ -1233,7 +1233,8 @@ Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{walk}{top\optional{, topdown\code{=True} - \optional{, onerror\code{=None}}}} + \optional{, onerror\code{=None}\optional{, + followlinks\code{=False}}}}} \index{directory!walking} \index{directory!traversal} \function{walk()} generates the file names in a directory tree, by @@ -1273,24 +1274,25 @@ report the error to continue with the walk, or raise the exception to abort the walk. Note that the filename is available as the \code{filename} attribute of the exception object. +By default, \function{walk()} will not walk down into symbolic links that +resolve to directories. Set \var{followlinks} to True to visit directories +pointed to by symlinks, on systems that support them. + \versionadded[The \var{followlinks} parameter]{2.6} \begin{notice} +Be aware that setting \var{followlinks} to true can lead to infinite recursion +if a link points to a parent directory of itself. \function{walk()} does not +keep track of the directories it visited already. +\end{notice} + +\begin{notice} If you pass a relative pathname, don't change the current working directory between resumptions of \function{walk()}. \function{walk()} never changes the current directory, and assumes that its caller doesn't either. \end{notice} -\begin{notice} -On systems that support symbolic links, links to subdirectories appear -in \var{dirnames} lists, but \function{walk()} will not visit them -(infinite loops are hard to avoid when following symbolic links). -To visit linked directories, you can identify them with -\code{os.path.islink(\var{path})}, and invoke \code{walk(\var{path})} -on each directly. -\end{notice} - This example displays the number of bytes taken by non-directory files in each directory under the starting directory, except that it doesn't look under any CVS subdirectory: |