def _iter_relative_dirs(dirname):
 if (not dirname):
  dirname = os.curdir
 try:
  files_or_dirs = os.listdir(dirname)
 except os.error:
  return
 for file_or_dir in files_or_dirs:
  (yield file_or_dir)
  path = os.path.join(dirname, file_or_dir)
  for sub_file_or_dir in _iter_relative_dirs(path):
   (yield os.path.join(file_or_dir, sub_file_or_dir))

def _iter_relative_dirs ( dirname ) : if ( not dirname ) : dirname = os . curdir try : files_or_dirs = os . listdir ( dirname ) except os . error : return for file_or_dir in files_or_dirs : ( yield file_or_dir ) path = os . path . join ( dirname , file_or_dir ) for sub_file_or_dir in _iter_relative_dirs ( path ) : ( yield os . path . join ( file_or_dir , sub_file_or_dir ) )
recursively iterates subdirectories of all levels from dirname .