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


Groups > comp.lang.python > #60361

Re: Importing by file name

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'subject:file': 0.07; 'deprecated': 0.09; 'python': 0.11; '24,': 0.16; 'for,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'happily': 0.16; 'internally': 0.16; 'knock': 0.16; 'pathname': 0.16; 'undocumented': 0.16; 'for?': 0.16; 'wrote:': 0.18; 'work,': 0.20; 'seems': 0.21; '>>>': 0.22; 'appears': 0.22; 'planned': 0.24; 'script.': 0.24; 'script': 0.25; 'equivalent': 0.26; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'appear': 0.29; 'chris': 0.29; 'am,': 0.29; 'absolute': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'file': 0.32; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'explains': 0.36; "didn't": 0.36; 'christian': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'expect': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'ian': 0.60; 'it!': 0.67; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=7JrQoUK1MmBFO5AgdBgs2b8uxu/M1XdlbB6Jl64Cf5I=; b=cmcuNzBcPXCfETR0sTl2bDbmC/oYWF7mKDfyn1lY+BVpish1TiFGN6Cd74jeUohIML WgMJpt2/zwN9q0IXNwPxgrmcIkUWk9G2ljahakYZkc56DJhiVhC1L6NhUxoDOR6KJZ+/ gqmZa21UWdTPtm6zSQjt8uJ87WvU/hnXfB8kPjGKIUJTifDwLP5/fTEjp2/BSOdXmWCP fVwnyxV9dMbcYVhNOjIaMyr42pVbfbzHCWkSb5B8QbV/wkoIAIk5Yi/naZWH4ML2CEQc YR+2M694rIpJDeCaPpLWI+d1RGKe804L5NaSWs1+41BOHup1TZdX+hkn2QascZOwO8m8 IqEg==
MIME-Version 1.0
X-Received by 10.66.25.36 with SMTP id z4mr5546538paf.101.1385291118066; Sun, 24 Nov 2013 03:05:18 -0800 (PST)
In-Reply-To <CALwzidmbQ8bOxZM6kfRe=z0i2S=srUs5tZ7feofCVL+0JKA7Mg@mail.gmail.com>
References <mailman.3114.1385264464.18130.python-list@python.org> <l6sg89$bns$1@dont-email.me> <CALwzidmbQ8bOxZM6kfRe=z0i2S=srUs5tZ7feofCVL+0JKA7Mg@mail.gmail.com>
Date Sun, 24 Nov 2013 22:05:17 +1100
Subject Re: Importing by file name
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3125.1385291127.18130.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385291127 news.xs4all.nl 15968 [2001:888:2000:d::a6]:33032
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60361

Show key headers only | 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