I have the following code to recursively list files within a directory:
from fnmatch import filter
from os import path, walk
def files_within(directory_path):
files_within = []
for root, directory_path, files_path in walk(directory_path):
for file_path in filter(files_path, "*"):
files_within.append(path.join(root, file_path))
return files_within
I want change it to avoid side affects. Is it possible?
I'm not using the glob because I'm using Python 2.5 because of a legacy code.