directory listing

Shi Mu samrobertsmith at gmail.com
Fri Nov 11 17:23:30 EST 2005


On 11 Nov 2005 22:00:04 GMT, Michael Konrad <mkonrad at syr.edu> wrote:
> Richard Townsend <richard at nospam.com> wrote:
>
> > On 11 Nov 2005 21:20:33 GMT, SU News Server wrote:
> >
> > Try passing the full pathname of each item to os.path.isdir()
> >
> > You can create the pathname using os.path.join(directory, x)
> >
> >
> >
>
> I wonder if I can join ./, so I don't have the full path in each
> entry?
>
> Thank you for responding.
> _Michael
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
I tried this and no error reported but nothing appear on the console, why?

import os

def buildList( directory='c:\TEMP' ):
    dirs = [ ]
    listing = os.listdir(directory)
    for x in listing:
        x = os.path.join(directory, x)
        print x
        if os.path.isdir(x):
            dirs.append(x)
    return dirs



More information about the Python-list mailing list