Python vs. Perl

Keith Dart kdart at
Tue Dec 14 08:48:09 CET 2004

Keith Dart wrote:
> Ian Bicking wrote:
>> Jon Perez wrote:
>>> Michael McGarry wrote:
>>>> I intend to use a scripting language for GUI development and front 
>>>> end code for my simulations in C. I want a language that can support 
>>>> SQL, Sockets, File I/O, and shell interaction.
>>> In my experience, Python is definitely much more suitable than Perl
>>> for the first four areas mentioned in the last sentence.  For the
>>> last area, I'm not sure, but Python's capabilities in this area are
>>> also quite good.
>> Shell interaction (or rather, external process interaction) is a lot 
>> better with Python 2.4's subprocess module.  Better or worse than 
>> Perl?  I'm not sure; generally I'd guess better, as it avoids the 
>> shell with all the shell's issues, and provides a more controlled 
>> programmatic way of interacting with subprocesses.  OTOH, Perl might 
>> have perfectly good modules for doing the same thing.  I can only say 
>> it's been missing for a while in Python, and it's good to see this 
>> done right.
> Yow, I must not get picked up in Google enough. ;-) The "proctools" 
> module in the pyNMS package <> has 
> been around for years. I use it all the time for shell-like stuff. There 
> is also an "expect" module, and the "termtools" module. If you need a 
> more complete process spawning and controlling framework then use pyNMS. 
>      It can "juggle" multiple processes, reaps child status (no 
> zombies), operates asynchronously (The ProcManager object is a SIGCHLD 
> handler), and works with pty's and pipes. It also offers a "thread-like" 
> interface  for Python subprocesses (uses fork). Can leave some fd's open 
> that you specify, can run the subprocess as a different user, and more...
> Check it out.

Oh, I forgot to mention that it also has a more user- and 
programmer-friendly ExitStatus object that processess can return. This 
is directly testable in Python:

proc = proctools.spawn("somecommand")
exitstatus = proc.wait()

if exitstatus:
	print "good result (errorlevel of zero)"
     print exitstatus # prints message with exit value

                            \/ \/
                            (O O)
-- --------------------oOOo~(_)~oOOo----------------------------------------
Keith Dart <kdart at>
vcard: <>
public key: ID: F3D288E4       URL: <>

More information about the Python-list mailing list