return values of os.system() on win32

rbt rbt at athop1.ath.vt.edu
Fri Jan 13 12:10:58 EST 2006


Peter Hansen wrote:
> rbt wrote:
> 
>> Is it safe to say that any value returned by os.system() other than 0 
>> is an error?
>>
>> if os.system('winver') != 0:
>>      print "Winver failed!"
>> else:
>>      print "Winver Worked."
> 
> 
> According to the docs, assuming that *in general* would be an error, but 
> it's likely that for the sorts of cases you are talking about, it's true.
> 
> Ultimately, since the return code is generally under the control of the 
> application you're calling, it's absolutely possible (likely) that there 
> are many programs which do not work as you assume above, and probably a 
> large number which don't ever explicitly set the return value at all...
> 
> -Peter
> 

OK, thanks guys. That's helpful... this is more of an MS issue than a 
Python issue.



More information about the Python-list mailing list