Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60362
| References | <mailman.3114.1385264464.18130.python-list@python.org> <l6sg89$bns$1@dont-email.me> <CALwzidmbQ8bOxZM6kfRe=z0i2S=srUs5tZ7feofCVL+0JKA7Mg@mail.gmail.com> <CAPTjJmrJOwyg-9_qESA0temJUzWw2zt9T2qnXMb4QK8ZHNWk0g@mail.gmail.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2013-11-24 04:37 -0700 |
| Subject | Re: Importing by file name |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3126.1385293064.18130.python-list@python.org> (permalink) |
On Sun, Nov 24, 2013 at 4:05 AM, Chris Angelico <rosuav@gmail.com> wrote:
> Undocumented... that explains why I didn't know about it! But that
> does appear to be what I'm looking for, so is there some equivalent
> planned as a replacement?
Hmm, playing around with importlib a bit, this seems to work:
from importlib import find_loader
loader = find_loader('spam', ['/path/to'])
if loader is not None:
module = loader.load_module()
The path passed to find_loader is searched instead of sys.path.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Importing by file name Chris Angelico <rosuav@gmail.com> - 2013-11-24 14:41 +1100
Re: Importing by file name Christian Gollwitzer <auriocus@gmx.de> - 2013-11-24 10:18 +0100
Re: Importing by file name Ian Kelly <ian.g.kelly@gmail.com> - 2013-11-24 02:50 -0700
Re: Importing by file name Chris Angelico <rosuav@gmail.com> - 2013-11-24 22:05 +1100
Re: Importing by file name Ian Kelly <ian.g.kelly@gmail.com> - 2013-11-24 04:37 -0700
csiph-web