Staging
v0.5.1
https://github.com/python/cpython
Revision 239197411080a3d41fd9ddca19aaa63c7aa9304e authored by Petri Lehtinen on 26 June 2012, 07:26:53 UTC, committed by Petri Lehtinen on 26 June 2012, 07:26:53 UTC
2 parent s 6c3f1dd + 969288e
Raw File
Tip revision: 239197411080a3d41fd9ddca19aaa63c7aa9304e authored by Petri Lehtinen on 26 June 2012, 07:26:53 UTC
Merge heads
Tip revision: 2391974
rmpyc.py
# Remove all the .pyc and .pyo files under ../Lib.


def deltree(root):
    import os
    from os.path import join

    npyc = npyo = 0
    for root, dirs, files in os.walk(root):
        for name in files:
            delete = False
            if name.endswith('.pyc'):
                delete = True
                npyc += 1
            elif name.endswith('.pyo'):
                delete = True
                npyo += 1

            if delete:
                os.remove(join(root, name))

    return npyc, npyo

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