-
-
Save BastinRobin/7d7466fe7d83ebec0ac19f314d590919 to your computer and use it in GitHub Desktop.
python script to convert all python .py files inside the current directory and all its subdirectories into .pyc and remove all .py files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import compileall | |
import os | |
# Get current working directory | |
curr_dir = os.getcwd() | |
# Compiles all python files to pyc | |
compileall.compile_dir(curr_dir, force=True) | |
# Recursively iterates to find .py files and remove them | |
for root, dirs, files in os.walk("."): | |
for file in files: | |
if file.endswith('.py'): | |
os.remove(os.path.join(root, file)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment