FAQ

On Mon, Jun 20, 2011 at 2:13 PM, Stephen Bunn 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

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 7 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedJun 20, '11 at 4:13a
activeJun 21, '11 at 12:34a
posts7
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase