How do I remove all .pyc files from a project?
find . -name '*.pyc' -delete
Surely the simplest.
Add to your ~/.bashrc
:
pyclean () {
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
}
This removes all .pyc and .pyo files, and __pycache__
directories. It's also very fast.
Usage is simply:
$ cd /path/to/directory
$ pyclean
find . -name "*.pyc" -exec rm -f {} \;