Remove All Files .pyc with Recrusive Method

Print   136 words   2018-12-30

I want to remove all files with .pyc extention. Doing it manually is hard and needs much time, so let’s create a simple python code to it for us.

This method simple but important. Example in your project dir is like this:

project_dir/
           __init__.py
           __init__.pyc
           something.py
           something.pyc
           ...
           core/
               __init__.py
               __init__.pyc
               build.py
               build.pyc

Deleting the .pyc files one by one would be spending a lot of time. and you will be bored. There is sample how to handle it.

$ find your_dir -name *.pyc -delete

Or, if you work inside current directory:

$ find . -name *.pyc -delete