Staging
v0.5.1
https://github.com/python/cpython
Revision d4c2177b780d3d4e23ed1d541d52b3a896b8c5c8 authored by Andrew M. Kuchling on 23 April 2006, 21:51:10 UTC, committed by Andrew M. Kuchling on 23 April 2006, 21:51:10 UTC
1 parent edb575e
Raw File
Tip revision: d4c2177b780d3d4e23ed1d541d52b3a896b8c5c8 authored by Andrew M. Kuchling on 23 April 2006, 21:51:10 UTC
Add two items
Tip revision: d4c2177
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