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/031487.html below:

[Python-Dev] Write All New Import Hooks (PEP 302) in Python, Not C

[Python-Dev] Write All New Import Hooks (PEP 302) in Python, Not CJust van Rossum just@letterror.com
Tue, 31 Dec 2002 15:09:37 +0100
[JvR]
> > but [sys.path_importer_cache is] not a new hook, it's a cache for
> > the path_hooks hook.  So I think the PEP proposes only two new
> > hooks.

[James C. Ahlstrom]
> I disagree.  It is publicly available in sys, and the PEP specifies
> it can be replaced or modified.  And if you want to add a hook, it
> is easier to put it into sys.path_importer_cache than to add it
> to the list in sys.path_hooks.  If you add it to sys.path_hooks,
> you must clear its entry in sys.path_importer_cache too.

This is all only half true. sys.path_importer_cache is exposed so you
can *clear* it in case you install a path hook that should take over
sys.path items that may already have a handler. To only partially clear
it is advanced usage. By no means you're supposed to *add* to
sys.path_importer_cache explicitly, as someone after you may clear it
again, and then you're hosed if there's no proper path hook.

I also disagree that adding an importer to sys.path_importer_cache would
always be *easier* than doing it the right way by adding a hook to
sys.path_hooks. If would be somewhat easier for "cookie" path items, but
I think in 99% of these cases a path-less importer on sys.meta_path
would work just as well.

I guess I should start on some proper documentation...

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