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


Groups > comp.lang.python > #8021

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!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'imports': 0.07; 'interpreter': 0.07; 'terry': 0.07; 'python': 0.08; 'builtin': 0.09; 'filename': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'reedy': 0.16; 'subject:scripts': 0.16; 'obviously': 0.17; 'script.': 0.19; 'jan': 0.20; 'header:In-Reply-To:1': 0.21; 'modify': 0.22; "doesn't": 0.25; 'subject: -- ': 0.25; 'function': 0.25; 'script': 0.27; 'work.': 0.28; 'thanks': 0.28; 'skip:_ 20': 0.28; 'problem': 0.28; 'subject:?': 0.29; 'import': 0.29; 'implement': 0.30; 'second': 0.30; 'it.': 0.31; 'separate': 0.31; 'header:X-Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'file': 0.34; 'header:User-Agent:1': 0.35; 'fails': 0.35; 'stephen': 0.37; 'put': 0.37; 'received:org': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60; 'ever': 0.64
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: running multiple scripts -- which way is more elegant?
Date Mon, 20 Jun 2011 13:48:34 -0400
References <BANLkTi=t9cHtPN6QOa4eUWuraZToOZxnoQ@mail.gmail.com> <BANLkTi=hHPo3ap9Cys40DX7wGdTEbn44OQ@mail.gmail.com> <BANLkTimBCVF7ed_sf3h-a4CA=gZpP4gCcA@mail.gmail.com> <BANLkTikpoGKrmNxYni+e+AcRiVzOEFWFQA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host rain.gmane.org
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10
In-Reply-To <BANLkTikpoGKrmNxYni+e+AcRiVzOEFWFQA@mail.gmail.com>
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.185.1308592128.1164.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 82.94.164.166
X-Trace 1308592128 news.xs4all.nl 49042 [::ffff:82.94.164.166]:33681
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8021

Show key headers only | View raw


On 6/20/2011 2:51 AM, Stephen Bunn wrote:

> Thanks for the replies. I would like to use the second method because I
> plan to implement everything in python.

The main problem of your second method is that you repeat the check 
function in each script. That will be a problem if you ever want to 
modify it. I might put is into a separate file and import into each script.

  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.)

Look at builtin function __import__(filename).


-- 
Terry Jan Reedy

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


Thread

Re: running multiple scripts -- which way is more elegant? Terry Reedy <tjreedy@udel.edu> - 2011-06-20 13:48 -0400

csiph-web