A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-December/030791.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
Thu, 5 Dec 2002 13:34:38 +0100
Martin v. L=F6wis wrote:

> "M.-A. Lemburg" <mal@lemburg.com> writes:
>=20
> > But why store the import objects in sys.path and not in
> > some auxilliary dictionary instead ?
>=20
> What would be the advantage of doing so?
>=20
> And, if this is done: How can I add my own custom import mechanism to
> sys.path? The machinery to replace strings in sys.path is only
> available for zip files, all other hooks must add their objects to
> sys.path directly.

+1

With MAL's idea you'd need to write

    p =3D ...
    sys.importers[p] =3D myimporter(p)
    sys.path.append(p)

instead of

    sys.path.append(myimporter(p))

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