def _pkgutil_submodule_names(modpath, with_pkg=False, with_mod=True):
package_name = modpath_to_modname(modpath)<EOL>if isfile(modpath):<EOL><INDENT>yield package_name<EOL><DEDENT>else:<EOL><INDENT>import pkgutil<EOL>prefix = package_name + '<STR_LIT:.>'<EOL>walker = pkgutil.walk_packages([modpath], prefix=prefix,<EOL>onerror=lambda x: None)  <EOL>for importer, modname, ispkg in walker:<EOL><INDENT>if not ispkg and with_mod:<EOL><INDENT>yield modname<EOL><DEDENT>elif ispkg and with_pkg:<EOL><INDENT>yield modname<EOL><DEDENT><DEDENT><DEDENT>
Ignore:
    x = sorted(submodule_paths(modname_to_modpath('ubelt')))
    y = sorted(_pkgutil_submodule_names(modname_to_modpath('ubelt')))
    x = [modpath_to_modname(p, hide_init=False, hide_main=False) for p in x]
    print('x = {!r}'.format(x))
    print('y = {!r}'.format(y))

Notes:
    this will take into account pyc files, we choose not to.