[Python-checkins] python/dist/src/Doc/lib libos.tex,1.120,1.121

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sun, 27 Apr 2003 19:09:47 -0700


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv16604/python/Doc/lib

Modified Files:
	libos.tex 
Log Message:
walk() docs:  Worked "walking" into the description and the text.  Added
a brief example where bottom-up walking is essential.


Index: libos.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v
retrieving revision 1.120
retrieving revision 1.121
diff -C2 -d -r1.120 -r1.121
*** libos.tex	25 Apr 2003 14:50:06 -0000	1.120
--- libos.tex	28 Apr 2003 02:09:43 -0000	1.121
***************
*** 1054,1058 ****
  \index{directory!walking}
  \index{directory!traversal}
! \function{walk()} generates the file names in a directory tree.
  For each directory in the tree rooted at directory \var{top} (including
  \var{top} itself), it yields a 3-tuple
--- 1054,1059 ----
  \index{directory!walking}
  \index{directory!traversal}
! \function{walk()} generates the file names in a directory tree, by
! walking the tree either top down or bottom up.
  For each directory in the tree rooted at directory \var{top} (including
  \var{top} itself), it yields a 3-tuple
***************
*** 1113,1116 ****
--- 1114,1133 ----
          dirs.remove('CVS')  # don't visit CVS directories
  \end{verbatim}
+ 
+ In the next example, walking the tree bottom up is essential:
+ \function{rmdir()} doesn't allow deleting a directory before the
+ directory is empty:
+ 
+ \begin{verbatim}
+ import os
+ from os.path import join
+ # Delete everything reachable from the directory named in 'top'.
+ for root, dirs, files in os.walk(top, topdown=False):
+     for name in files:
+         os.remove(join(root, name))
+     for name in dirs:
+         os.rmdir(join(root, name))
+ \end{verbatim}
+ 
  \versionadded{2.3}
  \end{funcdesc}