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 <rep...@bugs.python.org>
<http://bugs.python.org/issue17062>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to