Re: [Tutor] walking down directories

2006-03-18 Thread Alan Gauld
>I am trying to write a function that takes a > directory's name, finds any subdirectories, and then > prints out the size of the files in all found > directories. > As you see, the problem is that there is another > directory under testFiles called testDir, but the > function doesn't check the di

Re: [Tutor] walking down directories

2006-03-17 Thread Karl Pflästerer
On 17 Mrz 2006, [EMAIL PROTECTED] wrote: > As you see, the problem is that there is another > directory under testFiles called testDir, but the > function doesn't check the directory for files. The > function needs to find every directory (including > subdirectories within directories). Any hint

Re: [Tutor] walking down directories

2006-03-17 Thread Steve Slevinski
Recursion. if os.path.isdir(d): describeDirectory(d) Since your printing from the function itself, you may want to add a level or depth arguement with a default value of 0. def describeDirectory(directory, level=0): Then call the function recursively with describeDirectory(d,level+1) Use the

[Tutor] walking down directories

2006-03-17 Thread Christopher Spears
I am trying to write a function that takes a directory's name, finds any subdirectories, and then prints out the size of the files in all found directories. import os, os.path def describeDirectory(directory): dirList = [directory] for d in os.listdir(directory): if os.path.isdir(