Is python a good choice for this task?

Justin Sheehy justin at iago.org
Wed Nov 13 10:28:48 EST 2002


claird at lairds.com (Cameron Laird) writes:

>>why not recommend the "commands" module instead of popen for those uses?

> I claim to observe that Python adepts more rarely recommend commands
> than popen2.  I'll speculate that this is an artifact of commands'
> late appearance in Python's standard distribution (was it 1.5?).

Agreed.  I sometimes forget about its existence.

> *I*'ve never been able to get commands to do anything useful under Windows.

True enough.  However, in most cases where I've seen someone asking
how to get the output of some command inside a Python script, their
program was by its nature not going to be portable.  Thus, if commands
works on their platform, it may be the best choice for the job.

Mind, I do not claim that Python programs in general that use external
processes are not or can not be portable.  The difference is that the
people that were already writing portable code for this purpose didn't
have to ask how to spawn a subprocess.  <wink>

> at some point I need to figure out what my problems with commands on
> NT and W95 are

Sadly, I doubt that these problems are local to you.  From the docs:

"Availability: Unix."

It will generally import successfully on windows, but can not be
counted on to work there.  This is the real answer to my question.

The question was somewhat rhetorical.  I simply think that the
commands module occasionally deserves mention, even if it is not yet
as wonderfully portable as the rest of Python.

All of this said, I can't argue against the ease of use of [exec] and
similar facilities in Tcl.  I don't enjoy Tcl much myself, but that is
certainly one of its strengths.

-Justin

 








More information about the Python-list mailing list