how to add custom importer after the normal imports
ian.g.kelly at gmail.com
Thu Oct 9 00:44:04 CEST 2014
On Wed, Oct 8, 2014 at 4:53 AM, Gelonida N <gelonida at gmail.com> wrote:
> I just read about sys.meta_path, which allows to install custom importers
> *BEFORE* the default importers.
> However I have a use case where I would like to add a custom importer
> *AFTER* all other import methods have failed.
> Does anybody know how to do this.
> One way of implementing this would be to add the default importer as first
> entry in sys.meta_path. My only problem is, that I don't know how to create
> a 'default-importer', such that I can add it into sys.meta_path
As of CPython 3.3 the default importers are already in sys.meta_path,
so you could just add your custom importer to the end. If you need to
support earlier versions or alternate implementations then this may
not be reliable.
More information about the Python-list