blob: 019c69b16e79e21818e36f53a7799c75dbb1d8eb [file] [log] [blame]
Tim Peters6a9aec42001-02-11 00:46:39 +00001# Remove all the .pyc and .pyo files under ../Lib.
2
Tim Peters6a9aec42001-02-11 00:46:39 +00003def deltree(root):
4 import os
5 def rm(path):
6 os.unlink(path)
7 npyc = npyo = 0
8 dirs = [root]
9 while dirs:
10 dir = dirs.pop()
11 for short in os.listdir(dir):
12 full = os.path.join(dir, short)
13 if os.path.isdir(full):
14 dirs.append(full)
15 elif short.endswith(".pyc"):
16 npyc += 1
17 rm(full)
18 elif short.endswith(".pyo"):
19 npyo += 1
20 rm(full)
21 return npyc, npyo
22
23npyc, npyo = deltree("../Lib")
24print npyc, ".pyc deleted,", npyo, ".pyo deleted"