Importing by file name
Chris Angelico
rosuav at gmail.com
Sun Nov 24 06:05:17 EST 2013
On Sun, Nov 24, 2013 at 8:50 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Sun, Nov 24, 2013 at 2:18 AM, Christian Gollwitzer <auriocus at 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
More information about the Python-list
mailing list