Created
April 7, 2019 17:10
-
-
Save trishantpahwa/e13802dcfd1ff483ec20e86d94152bc1 to your computer and use it in GitHub Desktop.
A script to remove pyc files from a project.
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 os | |
import traceback | |
def traverse_directory(directories): | |
try: | |
for directory in directories: | |
if os.path.isdir(directory): | |
new_directories = os.listdir(directory) | |
for new_directory in new_directories: | |
new_directory = directory + '/' + new_directory | |
traverse_directory([new_directory]) | |
else: | |
if directory[-4:] == '.pyc': | |
print 'Removing pyc' | |
os.remove(directory) | |
except Exception: | |
print Exception | |
traceback.print_stack() | |
traverse_directory([os.getcwd()]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment