import os def walk_files(path, endpoint='.py'): file_list = [] for root, dirs, files in os.walk(path): for file in files: file_path = os.path.join(root, file) if file_path.endswith(endpoint): file_list.append(file_path) return file_list