SyntaxFix
Write A Post
Hire A Developer
Questions
A one-line solution to get only list of files (no subdirectories):
filenames = next(os.walk(path))[2]
or absolute pathnames:
paths = [os.path.join(path, fn) for fn in next(os.walk(path))[2]]