Here is the theory: the walk_packages function tries to import each specified module. When it falls into subpacket "Y", it tries to import it, but there is an error. By default, this error is suppressed. A side effect is that the walk_packages function does not regress in Y. You can test this theory using the keyword argument "onerror". For instance:
import sys, pkgutil from traceback import print_tb def onerror(name): print("Error importing module %s" % name) type, value, traceback = sys.exc_info() print_tb(traceback) import scenarios pkgutil.walk_packages(scenarios.__path__, scenarios.__name__ + '.', onerror=onerror)
source share