[New-bugs-announce] [issue17062] An os.walk inspired replacement for pkgutil.walk_packages

Nick Coghlan report at bugs.python.org
Mon Jan 28 12:17:08 CET 2013


New submission from Nick Coghlan:

I recently had occasion to use pkgutil.walk_packages, and my immediate thought was that it would have been a lot easier for me to use if it worked more like os.walk with topdown=True, producing tuples of (pkg, subpackages, modules)

"pkg" would be the package object at the current level (None for the top level)

"packages" would be a dictionary mapping fully qualified module names to loader objects for the subpackages (i.e. subdirectories)

"modules" would be a dictionary mapping fully qualified module names to loader objects for every submodule that wasn't a subpackage

As with editing the "subdirs" list with os.walk, editing the "packages" dictionary with this new API would keep the iterator from loading that subpackage and avoid recursing into it (this is the part I wanted in my current use case).

(This may even be PEP material, guiding some additions to the importer/finder API)

----------
components: Library (Lib)
messages: 180847
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: An os.walk inspired replacement for pkgutil.walk_packages
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17062>
_______________________________________


More information about the New-bugs-announce mailing list