Re: PEP 420 outstanding issues
"Eric V. Smith" <[email protected]>
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <[email protected]> |
On 5/11/2012 4:11 PM, PJ Eby wrote: > If find_loader() always returned a path for a package (even > non-namespace packages), then this would allow virtual paths to be made > either inclusive or exclusive of __init__ segments. That is, it would > let there be a transition period where you could explicitly declare a > namespace to get a mixed namespace, but by default the paths would be > exclusive. > > I'm not sure if anything I just said is clear without an example, so > I'll throw one in. Let's say somebody's writing code that spans > multiple Python versions, and they want their __init__-based namespace > packages to work, but be forward compatible with new subpackages using > PEP 420 portions. Basically, they write some code that calls > declare_namespace(), which then sets the module's __path__ to be an > "inclusive virtual" path. This path object is similar to the current > virtual path object, except that it *always* uses the second > find_loader() return value, even if the first value returned is not > None. Poof! Instant "transitional" namespace package, > backward-compatible with older Python versions, and forward-compatible > with PEP 420. But the second value (the paths) won't include anything on the parent path that occurs after __init__.py is found. Or am I missing something?