os.walk() dirs and files

Duncan Booth duncan.booth at invalid.invalid
Wed Feb 8 08:41:49 EST 2006


rtilley wrote:

> Just to clarify. In this particular case, I do not need to differentiate 
> between files and dirs... so would it be possible to do something such 
> as this:
> 

How about just concatentating the two lists:

> for root, dirs, files in os.walk(path):
>      for fs_object in files, dirs:
       for fs_object in files + dirs:
>          ADD fs_object to dictionary




More information about the Python-list mailing list