Why doesn't this work as expected?
Rainy
sill at optonline.net
Tue Jun 5 15:59:45 EDT 2001
On 5 Jun 2001 08:34:45 GMT, David LeBlanc <whisper at oz.nospamnet> wrote:
> I'm trying to build a directory walker, doing some work on each actual
> file found in each directory. However, when I run the below code snippet
> on a directory containing both sub-directories and files, it says that
> all are not dirs.
>
> What is not right?
>
> TIA,
>
> Dave LeBlanc
>
> import sys
> import os
> import dircache
> import re
>
>
> def getDirs():
> print dircache.listdir("l:/languages/python")
>
> for dir in dircache.listdir("l:/languages/C"):
> if os.path.isdir(dir):
> print dir, "is a dir"
> else:
> print dir, "is not a dir"
>
> getDirs()
Did you try os.path.walk?
--
Delay not, Caesar. Read it instantly.
-- Shakespeare, "Julius Caesar" 3,1
Here is a letter, read it at your leisure.
-- Shakespeare, "Merchant of Venice" 5,1
[Quoted in "VMS Internals and Data Structures", V4.4, when
referring to I/O system services.]
More information about the Python-list
mailing list