This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients ncoghlan
Date 2013-01-28.11:17:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359371828.89.0.768628623008.issue17062@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2013-01-28 11:17:08ncoghlansetrecipients: + ncoghlan
2013-01-28 11:17:08ncoghlansetmessageid: <1359371828.89.0.768628623008.issue17062@psf.upfronthosting.co.za>
2013-01-28 11:17:08ncoghlanlinkissue17062 messages
2013-01-28 11:17:08ncoghlancreate