module on files & directories

Robert Brewer fumanchu at amor.org
Thu Jan 13 11:50:19 EST 2005


Sara Fwd wrote:
> > Can anybody help me find a module or a function that
> > looks in a directory and defines whether the objects
> > in there are files or directories?

and Simon Brunning replied:
> See os.path.isfile() and os.path.isdir() -
> <http://docs.python.org/lib/module-os.path.html>.

I suspect you will also want to look at os.walk() eventually:

    for root, dirs, files in os.walk(path):
        for dir in dirs:
            do_something_with(dir)


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org



More information about the Python-list mailing list