[Tutor] WRITING XLS FROM OS.WALK()

Alan Gauld alan.gauld at btinternet.com
Sun Oct 10 10:17:38 CEST 2010


"Steven D'Aprano" <steve at pearwood.info> wrote

>> Only if glob now descends into the file system... which is why 
>> you'd
>> choose os.walk instead.

> Do you mean you want to point at a single directory and have it 
> search
> any and all subdirectories, no matter how deeply nested? Well, yes,
> that would be a good use-case for os.walk, and yes, I completely 
> missed
> it, so I withdraw my comment that Susana had re-invented the wheel.

I think the solution should use both. os.walk to traverse the 
directories
and glob to build the file list at each level.  Each tool has its 
role.
I didn't see anything untoward in recommending glob to replace
the use of the string based list comp for selection of the files,
I just assemed you meant in conjunction with os.walk!.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list