Quick & Dirty python recursive folder search

Someone asked how to have python recursively search a folder structure. There may be a better way but this is how I typically do it–it basically starts with one directory and loops through the contents compiling a list of sub-directories as it goes through the contents.


import glob, os

theDir = 'c:/temp/'
theDirList = []

while len(theDirList) > 0:
    newDirList = []
    for iDir in theDirList:
        print iDir
        for iFile in glob.glob(iDir+"/*"):
            if (os.path.isdir(iFile)):

    theDirList = newDirList