diff options
author | Guido van Rossum <guido@python.org> | 2003-05-13 18:01:19 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-05-13 18:01:19 (GMT) |
commit | bf1bef820c5af6b0a9a60abe1564ac35f036fdcb (patch) | |
tree | 28ff811dc3667e9efb3d021270c4a547f35c30c2 /Doc/lib/libos.tex | |
parent | a2f7728341956963c6088c7ba5076da0b9c1e6dd (diff) | |
download | cpython-bf1bef820c5af6b0a9a60abe1564ac35f036fdcb.zip cpython-bf1bef820c5af6b0a9a60abe1564ac35f036fdcb.tar.gz cpython-bf1bef820c5af6b0a9a60abe1564ac35f036fdcb.tar.bz2 |
Add optional 'onerror' argument to os.walk(), to control error
handling.
Diffstat (limited to 'Doc/lib/libos.tex')
-rw-r--r-- | Doc/lib/libos.tex | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex index dd492bb..074d332 100644 --- a/Doc/lib/libos.tex +++ b/Doc/lib/libos.tex @@ -1054,7 +1054,8 @@ which is used to set the access and modified times, respectively. Availability: Macintosh, \UNIX, Windows. \end{funcdesc} -\begin{funcdesc}{walk}{top\optional{, topdown\code{=True}}} +\begin{funcdesc}{walk}{top\optional{, topdown\code{=True} + \optional{, onerror\code{=None}}}} \index{directory!walking} \index{directory!traversal} \function{walk()} generates the file names in a directory tree, by @@ -1087,6 +1088,13 @@ about directories the caller creates or renames before it resumes false is ineffective, because in bottom-up mode the directories in \var{dirnames} are generated before \var{dirnames} itself is generated. +By default errors from the \code{os.listdir()} call are ignored. If +optional argument \var{onerror} is specified, it should be a function; +it will be called with one argument, an os.error instance. It can +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. + \begin{notice} If you pass a relative pathname, don't change the current working directory between resumptions of \function{walk()}. \function{walk()} |