Re: PEP 420 issue: extend_path

"Eric V. Smith" <[email protected]>
Newsgroups gmane.comp.python.import
Message-ID <[email protected]>
On 05/08/2012 10:07 AM, Eric V. Smith wrote:

> I don't disagree with this. But we've got a function that we're asking
> to return one of 2 things, as you say. How is this normally handled? I
> would not use a callback. I'd return a tuple with the two things:
> (loader, list_of_portions). That seems way more straightforward.

In the pep-420 branch I've checked in code where find_loader() returns
(loader, list_of_portions). I've implemented it for the FileFinder and
zipimport.

loader can be None or a loader object.
list_of_portions can be an empty list, or a list of strings.

To indicate "no loader or portions found", return (None, []).

If loader is not None, list_of_portions is ignored.

I'm pretty happy with this API. Comments welcome.

Eric.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.