Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78888
| From | Gelonida N <gelonida@gmail.com> |
|---|---|
| Subject | Re: how to add custom importer after the normal imports |
| Date | 2014-10-09 14:51 +0200 |
| References | <m1353n$dpu$1@ger.gmane.org> <CALwzidnxJs8U+vsG7b6=W8TnRRHROBo0UMQc_uFqjx_t-5Fgkw@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14713.1412859107.18130.python-list@python.org> (permalink) |
On 10/9/2014 12:44 AM, Ian Kelly wrote: > On Wed, Oct 8, 2014 at 4:53 AM, Gelonida N <gelonida@gmail.com> wrote: >> Hi, >> >> >> 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. > thanks for your answer. I'm using Puthon 2.7 for the given project and there sys.meta_path is []. Just for fun I started Python3.3 and looked at it's meta_path, which contained for example _frozen_importlib.PathFinder Unfortunately python 2.7 does not seem to have the package _frozen_importlib So now the question seems to boil down to looking for the 2.7 equivalent of python 3.3's _frozen_importlib.PathFinder
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: how to add custom importer after the normal imports Gelonida N <gelonida@gmail.com> - 2014-10-09 14:51 +0200
csiph-web