Created
September 26, 2016 12:33
-
-
Save AnnamalaiNagappan/655db51d2d4766a923e5332e16813a95 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 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
Its a wonderful code :)