Determining whether it's a file or a directory?
__peter__ at web.de
Fri Oct 8 11:50:59 CEST 2004
> os.listdir("path") returns the names of all the items in a directory ok,
> but I need to know whether the item is a file or a directory.
> Can anybody tell me how this could be done?
The standard way would be to perform
on the item in question, but
>>> import os
>>> for path, dirs, files in os.walk("path"):
gives you directories and files in separate lists.
More information about the Python-list