sayatul
11/23/2017 - 4:52 PM

Removes all pyc files from directory

Removes all pyc files from directory

# Remove Pyc File
# $@Y Atul Yadav

import os

def remove_pyc(path):
	for dirpath, subdirs, files in os.walk(path):
	    for x in files:
	        if x.endswith(".pyc"):
	        	print(dirpath+"/"+x)
	        	os.remove(dirpath+"/"+x)

def main():
	print("Select From Below: \n 1. Enter Path \n 2. Current Dir")
	choice = int(input("Enter your choice: "))

	if choice == 1:
		print("Enter the full path for Directory")
		path = input()

	elif choice == 2:
		path = '.'

	remove_pyc(path)

if __name__ == '__main__':
	main()