(root)
| 2 | |
| 3 | |
| 4 | def deltree(root): |
| 5 | import os |
| 6 | from os.path import join |
| 7 | |
| 8 | npyc = 0 |
| 9 | for root, dirs, files in os.walk(root): |
| 10 | for name in files: |
| 11 | # to be thorough |
| 12 | if name.endswith(('.pyc', '.pyo')): |
| 13 | npyc += 1 |
| 14 | os.remove(join(root, name)) |
| 15 | |
| 16 | return npyc |
| 17 | |
| 18 | npyc = deltree("../Lib") |
| 19 | print(npyc, ".pyc deleted") |