On 10/04/2008, Soren <[EMAIL PROTECTED]> wrote: > Hi, > > I'd like to read the filenames in a directory, but not the > subdirectories, os.listdir() gives me everything... how do I separate > the directory names from the filenames? Is there another way of doing > this?
The only thing I can think of if you just want the immediate dir is to use the os.path module's function isfile to test each item from the list returned by os.listdir. This should do the trick I think: [ f for f in os.listdir('pathname') if os.path.isfile(f) ] cheers Dave -- http://mail.python.org/mailman/listinfo/python-list