How do I limit os.walk to only return files in the directory I provide it?
os.walk
def _dir_list(self, dir_name, whitelist): outputList = [] for
A slight change to Alex's answer, but using __next__():
__next__()
print(next(os.walk('d:/'))[2]) or print(os.walk('d:/').__next__()[2])
print(next(os.walk('d:/'))[2])
print(os.walk('d:/').__next__()[2])
with the [2] being the file in root, dirs, file mentioned in other answers
[2]
file
root, dirs, file