please help me understand os.system() result

Donn Cave donn at
Tue May 20 13:03:23 EDT 2003

Quoth Erik Max Francis <max at>:
|> 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 =
   >>> x = fp.close()
   >>> print x

   fp = os.popen('echo hi; exit 0', 'r')
   >>> t =
   >>> x = fp.close()
   >>> print x

Can't think of any good reason for this, right off hand, but it
has always been thus.

	Donn Cave, donn at

More information about the Python-list mailing list