def top_python_dirs(dirname):
 top_dirs = []
 dir_init = os.path.join(dirname, '__init__.py')
 if os.path.exists(dir_init):
  top_dirs.append(dirname)
 for directory in ['djangoapps', 'lib']:
  subdir = os.path.join(dirname, directory)
  subdir_init = os.path.join(subdir, '__init__.py')
  if (os.path.exists(subdir) and (not os.path.exists(subdir_init))):
   dirs = os.listdir(subdir)
   top_dirs.extend((d for d in dirs if os.path.isdir(os.path.join(subdir, d))))
 return top_dirs

def top_python_dirs ( dirname ) : top_dirs = [ ] dir_init = os . path . join ( dirname , '__init__.py' ) if os . path . exists ( dir_init ) : top_dirs . append ( dirname ) for directory in [ 'djangoapps' , 'lib' ] : subdir = os . path . join ( dirname , directory ) subdir_init = os . path . join ( subdir , '__init__.py' ) if ( os . path . exists ( subdir ) and ( not os . path . exists ( subdir_init ) ) ) : dirs = os . listdir ( subdir ) top_dirs . extend ( ( d for d in dirs if os . path . isdir ( os . path . join ( subdir , d ) ) ) ) return top_dirs
find the directories to start from in order to find all the python files in dirname .