Python vs. Perl
Nick Craig-Wood
nick at craig-wood.com
Tue Dec 14 05:30:02 EST 2004
Keith Dart <kdart at kdart.com> wrote:
> 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)"
> else:
> print exitstatus # prints message with exit value
This sounds rather like the new subprocess module...
>>> import subprocess
>>> rc = subprocess.call(["ls", "-l"])
total 381896
-rw-r--r-- 1 ncw ncw 1542 Oct 12 17:55 1
[snip]
-rw-r--r-- 1 ncw ncw 713 Nov 16 08:18 z~
>>> print rc
0
IMHO the new subprocess module is a very well thought out interface...
--
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list