directory listing

Fredrik Lundh fredrik at pythonware.com
Fri Nov 11 17:29:34 EST 2005


Shi Mu wrote:

> 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

is that the entire script?  you're defining a function, but you're
not calling it.  try adding

    print buildList()

at the end of the script.

</F>






More information about the Python-list mailing list