Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60361

Re: Importing by file name

References <mailman.3114.1385264464.18130.python-list@python.org> <l6sg89$bns$1@dont-email.me> <CALwzidmbQ8bOxZM6kfRe=z0i2S=srUs5tZ7feofCVL+0JKA7Mg@mail.gmail.com>
Date 2013-11-24 22:05 +1100
Subject Re: Importing by file name
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3125.1385291127.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Nov 24, 2013 at 8:50 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Sun, Nov 24, 2013 at 2:18 AM, Christian Gollwitzer <auriocus@gmx.de> wrote:
>> Am 24.11.13 04:41, schrieb Chris Angelico:
>>
>>> As part of a post on python-ideas, I wanted to knock together a quick
>>> little script that "imports" a file based on its name, in the same way
>>> that the Python interpreter will happily take an absolute pathname for
>>> the main script.
>>
>>
>> Is it imp.load_source() that you are looking for?
>
> That appears to work, but I note that it's undocumented and seems to
> be used internally only by the deprecated load_module function.  I
> expect it will likely be removed in Python 3.5.

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?

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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