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


Groups > comp.lang.python > #8014

Re: running multiple scripts -- which way is more elegant?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <florencio.cano@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'imports': 0.07; 'interpreter': 0.07; 'python': 0.08; 'filename': 0.09; 'this:': 0.10; 'subject:scripts': 0.16; 'cc:addr:python-list': 0.17; 'obviously': 0.17; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; "doesn't": 0.25; 'subject: -- ': 0.25; 'script': 0.27; 'work.': 0.28; 'message-id:@mail.gmail.com': 0.28; 'skip:_ 20': 0.28; 'subject:?': 0.29; 'import': 0.29; 'cc:addr:python.org': 0.30; 'received:209.85.210.46': 0.30; 'received:mail-pz0-f46.google.com': 0.30; 'fails': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'to:none': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=FoqU8W2XnlLhmcIi1z9H+Wab7PTKR23YrPlAZJciCcM=; b=RyUaPKuLn5KxW3vOgxOP8LysnXd/7pctwoZbXlhk7li++1JZwSc2EbEkIkZv7qh8i/ D/oVl21wRLwjygKStKNbCvj2E0p1f7GQAFpq0Xs3UwvAmQq3o3dSnsGF9SzO+CbW4x8j HOoS7+HuvHA1mGSuKEttWLXP+ndT4OZznxoLo=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; b=m5b0UdWdFr4Re7cK01vN6z5yI8svrMxrtUOvE999dAZr1g2bGNHk0FMdRH3mj2dufU 2iWdEzDlSkmRlSf9Cz21SZu6R0PrvOu1Pbd19uw08pXpQtB0Dmm4Zv5WkEaBVNF0AhxA xL6ugzjsY8IB/yeJQZ7qDanda47FgHOQcZV60=
MIME-Version 1.0
In-Reply-To <BANLkTikpoGKrmNxYni+e+AcRiVzOEFWFQA@mail.gmail.com>
References <BANLkTi=t9cHtPN6QOa4eUWuraZToOZxnoQ@mail.gmail.com> <BANLkTi=hHPo3ap9Cys40DX7wGdTEbn44OQ@mail.gmail.com> <BANLkTimBCVF7ed_sf3h-a4CA=gZpP4gCcA@mail.gmail.com> <BANLkTikpoGKrmNxYni+e+AcRiVzOEFWFQA@mail.gmail.com>
Date Mon, 20 Jun 2011 16:19:55 +0200
Subject Re: running multiple scripts -- which way is more elegant?
From Florencio Cano <florencio.cano@gmail.com>
Cc python-list@python.org
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.181.1308579599.1164.python-list@python.org> (permalink)
Lines 10
NNTP-Posting-Host 82.94.164.166
X-Trace 1308579599 news.xs4all.nl 49181 [::ffff:82.94.164.166]:38818
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8014

Show key headers only | View raw


> Unfortunately I have not been able to
> work out how to get the imports to work.
>
> import config_script obviously doesn't work and __import__(config_script)
> works from the python interpreter but fails in the script (ImportError:
> Import by filename is not supported.)

You can use this:

exec("import " + module_name)

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


Thread

Re: running multiple scripts -- which way is more elegant? Florencio Cano <florencio.cano@gmail.com> - 2011-06-20 16:19 +0200

csiph-web