Skip to content

Instantly share code, notes, and snippets.

@gtechsltn
Forked from technocake/pyclean.sh
Created January 29, 2024 04:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtechsltn/5767aa50b6f44e53f7438dd3eb85db9d to your computer and use it in GitHub Desktop.
Save gtechsltn/5767aa50b6f44e53f7438dd3eb85db9d to your computer and use it in GitHub Desktop.
Clear all python cache in directory
# pyclean command to clear all python cache in a directory
# source: https://stackoverflow.com/questions/28991015/python3-project-remove-pycache-folders-and-pyc-files
# in .bash_profile / .bash_rc etc put:
pyclean () {
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
}
# Now to delete all python cache in a directory do:
cd path/to/directory
pyclean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment