PDA

View Full Version : [SOLVED] Python: For...in... & recursive search



jesuisbenjamin
November 4th, 2009, 11:45 AM
Hello forum, ):P

With Python i would like to iterate through files in a directory and its sub-directories.
Is there any means to make for...in... recursive, or do i need to create a function to find directories and add them to the list of directories to iterate?

Thanks for the tips!

Bjalf
November 4th, 2009, 11:53 AM
Check out os.walk() and os.path.walk()
http://docs.python.org/library/os.html#os.walk
http://docs.python.org/library/os.path.html#os.path.walk

ghostdog74
November 4th, 2009, 12:15 PM
use os.walk() and not os.path.walk()