Re: PEP 420: Implicit Namespace Packages
Nick Coghlan <[email protected]>
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CADiSq7dTOu4S0cVwbtZcfuWhuO7stcShLbZa+BE0ZKy3LLhfmQ@mail.gmail.com> |
On Sun, Apr 22, 2012 at 11:06 AM, Eric V. Smith <[email protected]> wrote: > Furthermore, given how __path__ is built, by one-at-a-time remembering > the path entries that have a foo directory but no foo/__init__.py, I'm > not sure how you'd turn that into some auto-updating iterable. You just have to remember all your namespace packages somewhere and then use a list subclass that triggers a rescan whenever the contents change. Personally, I'm happier with the basic behaviour being that dynamically updating sys.path while the program is running can be a bit hit-or-miss in terms of what recognises the change. Longer term, rather than introducing magical side effects for sys.path manipulation, I think the better solution is to expose a more object-oriented API for manipulating the import system state that takes care of maintaining the state invariants, invalidating caches when appropriate and triggering updates to package __path__ entries. Hence, PEP 406 (currently deferred) and its import engine API. Cheers, Nick. -- Nick Coghlan | [email protected] | Brisbane, Australia