Staging
v0.5.1
https://github.com/python/cpython
Revision d2f3857c40a340f252397eb16b4289403af8bf76 authored by Georg Brandl on 30 January 2011, 08:37:19 UTC, committed by Georg Brandl on 30 January 2011, 08:37:19 UTC
Patch by Ron Adam, reviewed by Eric Araujo.
1 parent ce227e3
Raw File
Tip revision: d2f3857c40a340f252397eb16b4289403af8bf76 authored by Georg Brandl on 30 January 2011, 08:37:19 UTC
#10961: fix exception handling in new pydoc server code.
Tip revision: d2f3857
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