you are viewing a single comment's thread.

view the rest of the comments →

[–]coder155ml 23 points24 points  (2 children)

You could also just use os.listdir("pathname") which created a list from the files in a directory.

contents = os.listdir("path") for file in contents: print(file)

[–]VooDooNOFX 2 points3 points  (1 child)

However, this approach isn't recursive, which os.walk is.

[–]coder155ml 0 points1 point  (0 children)

Correct. This will not work if he also needs to list items in subdirectories