summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libos.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/lib/libos.tex')
-rw-r--r--Doc/lib/libos.tex24
1 files changed, 14 insertions, 10 deletions
diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex
index cbb35f3..638ed6b 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,6 +1274,18 @@ 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()}
@@ -1280,15 +1293,6 @@ 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: