[Python-Dev] new import hooks & zip import
Just van Rossum
just@letterror.com
Thu, 12 Dec 2002 15:53:05 +0100
Skip Montanaro wrote:
> Scanning the patch summary I see:
>
> sys.path_hooks is a list of callable objects that take
> a string as their only argument. A hook will be called
> with a sys.path or pkg.__path__ item. It should return
> an "importer" object (see below), or raise ImportError
> or return None if it can't deal with the path item. By
> default, sys.path_hooks only contains the zipimporter
> type, if the zipimport module is available.
>
> Why have it raise ImportError or return None if it can't deal with the path
> item? Shouldn't there be only one way to report failure? (Or do I misread
> your explanation?)
No, you read correctly... I'm not sure, I just thought if might be convenient to
also be able to return None. I'd be happy to stick with just one way, though
(which would be raising ImportError, as that's easiest from __init__ methods).
Just