directory-walk

Quicker to os.walk or glob?

Quicker to os.walk or glob? Question: I’m messing around with file lookups in python on a large hard disk. I’ve been looking at os.walk and glob. I usually use os.walk as I find it much neater and seems to be quicker (for usual size directories). Has anyone got any experience with them both and could …

Total answers: 4

What is the Python way to walk a directory tree?

What is the Python way to walk a directory tree? Question: I feel that assigning files, and folders and doing the += [item] part is a bit hackish. Any suggestions? I’m using Python 3.2 from os import * from os.path import * def dir_contents(path): contents = listdir(path) files = [] folders = [] for i, …

Total answers: 14