please help me understand os.system() result
Donn Cave
donn at u.washington.edu
Tue May 20 13:03:23 EDT 2003
Quoth Erik Max Francis <max at alcyone.com>:
|> Please note that wait, system and the like have quite a tendency to
|> return None
|> if the command ran to completion without problem, so you're unlikely
|> to get 0 as
|> a result.
|
| I'm not sure what this means; under what circumstances does it return
| None? Doing so would violate the specification as laid out in the
| documentation.
He was probably actually thinking of popen() --
fp = os.popen('echo hi; exit 7', 'r')
>>> t = fp.read()
>>> x = fp.close()
>>> print x
1792
fp = os.popen('echo hi; exit 0', 'r')
>>> t = fp.read()
>>> x = fp.close()
>>> print x
None
Can't think of any good reason for this, right off hand, but it
has always been thus.
Donn Cave, donn at u.washington.edu
More information about the Python-list
mailing list