[Python-checkins] python/dist/src/Doc/lib libos.tex,1.144,1.145

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Mon Nov 22 17:49:05 CET 2004


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21891/Doc/lib

Modified Files:
	libos.tex 
Log Message:
SF bug 1071087: os.walk example for deleting a full tree is sometime wrong.

Clarify that the example assumes no links are present; the point of the
example is to illustrate a need for topdown=False, not to wrestle with
platform-dependent link convolutions.

Also spell os.path.join() out in full, instead of using a shortcut import.
The bug reporter was confused by that too, and it's clearer this way.

Bugfix candidate; but I don't intend to backport it.


Index: libos.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- libos.tex	4 Nov 2004 21:27:48 -0000	1.144
+++ libos.tex	22 Nov 2004 16:49:02 -0000	1.145
@@ -1185,16 +1185,16 @@
 directory is empty:
 
 \begin{verbatim}
-import os
-from os.path import join
-# Delete everything reachable from the directory named in 'top'.
+# Delete everything reachable from the directory named in 'top',
+# assuming there are no symbolic links.
 # CAUTION:  This is dangerous!  For example, if top == '/', it
 # could delete all your disk files.
+import os
 for root, dirs, files in os.walk(top, topdown=False):
     for name in files:
-        os.remove(join(root, name))
+        os.remove(os.path.join(root, name))
     for name in dirs:
-        os.rmdir(join(root, name))
+        os.rmdir(os.path.join(root, name))
 \end{verbatim}
 
 \versionadded{2.3}



More information about the Python-checkins mailing list