[Tutor] Reading directory contents
tpc at csua.berkeley.edu
tpc at csua.berkeley.edu
Fri Aug 29 12:01:14 EDT 2003
hi Mike, what are you trying to do ? For what it's worth, I have some
code that traverses a directory tree recursively, starting at my web
server document root, and indexes all *.HTML pages. Not sure if this is
up your alley:
<code>
APACHE_ROOT_DIR = '' # you put in your path here
newList = []
def htmlFinder(arg, dirname, fnames):
for fn in fnames:
if fn.endswith('.html'):
path = os.path.join(dirname, fn)
newList.append(path)
os.path.walk(APACHE_ROOT_DIR, htmlFinder, None)
return newList
</code>
I hope that helps you.
On 29 Aug 2003, Mike Wagman wrote:
> I need some code to load and parse file directories. Can anyone either
> send me some sample code, or a site that talks about this issue.
> Thanks
> Mike
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list