A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-December/030728.html below:

[Python-Dev] New and Improved Import Hooks

[Python-Dev] New and Improved Import Hooks [Python-Dev] New and Improved Import HooksJust van Rossum just@letterror.com
Wed, 4 Dec 2002 12:52:39 +0100
Fredrik Lundh wrote:

> what's wrong with:
> 
> #4
>     for path in sys.path:
>         if isinstance(path, types.StringTypes):
>             do_standard_import(...)
>         else:
>             path.do_import(...)

That, or what Jack said, which I think is even better:

#5
    for path in sys.path:
        if hasattr(path, "find_module"):
            loader = path.find_module(name)
        if isinstance(path, types.StringTypes):
            do_standard_import(...)
        else:
            pass

(I originally thought it might be important that path elements be str
subclasses, but I'm not so sure anymore. Especially after I wrote a str subclass
in C: it's a HUGE pain ;-)

Just



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4