walk() docs: Emphasize that the recursive-delete example is dangerous.
This commit is contained in:
parent
5501b5e3d7
commit
a390c6e194
|
@ -1126,6 +1126,8 @@ directory is empty:
|
||||||
import os
|
import os
|
||||||
from os.path import join
|
from os.path import join
|
||||||
# Delete everything reachable from the directory named in 'top'.
|
# Delete everything reachable from the directory named in 'top'.
|
||||||
|
# CAUTION: This is dangerous! For example, if top == '/', it
|
||||||
|
# could delete all your disk files.
|
||||||
for root, dirs, files in os.walk(top, topdown=False):
|
for root, dirs, files in os.walk(top, topdown=False):
|
||||||
for name in files:
|
for name in files:
|
||||||
os.remove(join(root, name))
|
os.remove(join(root, name))
|
||||||
|
|
Loading…
Reference in New Issue