Staging
v0.5.1
https://github.com/python/cpython
Revision 1f92d72b9c5a2bb3a39443447f1ddaecf0745e72 authored by Tim Peters on 25 March 2002, 19:28:43 UTC, committed by Tim Peters on 25 March 2002, 19:28:43 UTC
1 parent 6403be2
Raw File
Tip revision: 1f92d72b9c5a2bb3a39443447f1ddaecf0745e72 authored by Tim Peters on 25 March 2002, 19:28:43 UTC
Bump release to 2.2.1c2.
Tip revision: 1f92d72
rmpyc.py
# Remove all the .pyc and .pyo files under ../Lib.

def deltree(root):
    import os
    def rm(path):
        os.unlink(path)
    npyc = npyo = 0
    dirs = [root]
    while dirs:
        dir = dirs.pop()
        for short in os.listdir(dir):
            full = os.path.join(dir, short)
            if os.path.isdir(full):
                dirs.append(full)
            elif short.endswith(".pyc"):
                npyc += 1
                rm(full)
            elif short.endswith(".pyo"):
                npyo += 1
                rm(full)
    return npyc, npyo

npyc, npyo = deltree("../Lib")
print npyc, ".pyc deleted,", npyo, ".pyo deleted"
back to top