def _iter_modules(path):
 import os
 import pkgutil
 if hasattr(pkgutil, 'iter_modules'):
  for (importer, modname, ispkg) in pkgutil.iter_modules(path):
   (yield (modname, ispkg))
  return
 from inspect import getmodulename
 from pydoc import ispackage
 found = set()
 for path in path:
  for filename in os.listdir(path):
   p = os.path.join(path, filename)
   modname = getmodulename(filename)
   if (modname and (modname != '__init__')):
    if (modname not in found):
     found.add(modname)
     (yield (modname, ispackage(modname)))

def _iter_modules ( path ) : import os import pkgutil if hasattr ( pkgutil , 'iter_modules' ) : for ( importer , modname , ispkg ) in pkgutil . iter_modules ( path ) : ( yield ( modname , ispkg ) ) return from inspect import getmodulename from pydoc import ispackage found = set ( ) for path in path : for filename in os . listdir ( path ) : p = os . path . join ( path , filename ) modname = getmodulename ( filename ) if ( modname and ( modname != '__init__' ) ) : if ( modname not in found ) : found . add ( modname ) ( yield ( modname , ispackage ( modname ) ) )
iterate over all modules in a package .