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


Groups > comp.lang.python > #7997 > unrolled thread

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

Started byChris Angelico <rosuav@gmail.com>
First post2011-06-20 14:26 +1000
Last post2011-06-20 14:26 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: running multiple scripts -- which way is more elegant? Chris Angelico <rosuav@gmail.com> - 2011-06-20 14:26 +1000

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

FromChris Angelico <rosuav@gmail.com>
Date2011-06-20 14:26 +1000
SubjectRe: running multiple scripts -- which way is more elegant?
Message-ID<mailman.168.1308544021.1164.python-list@python.org>
On Mon, Jun 20, 2011 at 2:13 PM, Stephen Bunn <scbunn@sbunn.org> wrote:
> List,
>
>   First I'm very new to Python. I usually do this kind of thing with shell
> scripts, however, I'm trying to move to using python primarily so I can
> learn the language.

A worthy cause :)

> ...  I have come up with two ways to
> accomplish what I'm trying to do and I'm looking for the more elegant
> solution -- or if there is another solution that I have not thought of.  Any
> input would be greatly appreciated and thanks for your time.

Your first method is language-independent. The underlying scripts
merely need to be legal shell scripts and they will work. This is a
measure of flexibility that may be of value.

Your second method, on the other hand, avoids reinvoking Python and
myriad processes, which may work out to be rather faster. Also, you
could have the scripts communicate back to the main module more
easily.

I'd be inclined toward the second solution if I'm writing all the code
myself, but very definitely the first if someone else might write one
of the subscripts (especially so if this is going to be distributed
widely) - spawning a new process means that the system's isolation of
processes keeps your system safe. If you don't need that measure of
protection, I would still surround the import and check() call with
try/except and gracefully handle any errors.

There's many ways these things can be done, but I think you've already
hit on the two broad types (import the code, or use stdout/rc).

Chris Angelico

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web