Why does this recursive function keep returning multiple dictionaries instead of just one.
def retFiles(dir):
data = {}
root = set()
os.chdir(dir)
cwd = os.getcwd()
for i in os.listdir(cwd):
if os.path.isfile(i):
data.setdefault(i, set())
root.add(os.path.relpath(dir).replace("\\", "/"))
data[i] = root
else:
preisci(i)
print(data)
Actually it makes sense why the method would return a list of lists (if the print(data) line is actually supposed to be the return).
The line
is assigning a list of paths to the i’th index of data. So if we are supposed to be returning data then data will contain multiple lists of paths.