newbie wants to compile python list of filenames in selected directories

John J. Lee jjl at pobox.com
Sun Feb 6 15:16:02 EST 2005


Greg Krohn <greg at invalid.invalid> writes:
> anthonyberet wrote:
[...]
> > I want to write a script to compare filenames in chosen directories,
> > on windows machines. Ideally it would compose a list of strings of
> > all the filenames in the directories, and those directories would be
> > chosable by the user of the script.
[...]
> 
> os.listdir does almost exactly what you are asking for. For a little
> more flexibility, you can use os.path.walk, although it's not quite as
> newb friendly.
> 
> -greg

os.walk is perhaps newbie-friendlier than os.path.walk.

Or perhaps not: not having read the tutorial &c. for some time, I
don't know how good they are on generators...


John



More information about the Python-list mailing list