directory listing
SU News Server
mkonrad at syr.edu
Fri Nov 11 16:20:33 EST 2005
I've struggled with this for quite a while and I'm am just not sure
what is going on. I have the following code
import os
def buildList( directory='/Users/mkonrad' )
dirs = [ ]
listing = os.listdir(directory)
for x in listing:
if os.path.isdir(x):
dirs.append(x)
return dirs
This always returns an empty list.
Now if I change it so that directory='.' or directory=os.getcwd()
Then it returns a list of directories.
Any ideas?
Thank you,
-Michael
More information about the Python-list
mailing list