os.system() question

Bryan Irvine sparctacus at gmail.com
Mon Oct 19 14:14:22 EDT 2009


I'm a python n00b and so pardon me in advance if this is really stupid
question.

I have my suspicions but why does the following not work the way I'm
anticipating it will?

(python 2.4.4)

>>> import os
>>> if (os.system('echo test')):
...    print 'success'
... else:
...    print 'failed'
...
test
failed
>>> if (os.system('echosadf test')):
...    print 'success'
... else:
...    print 'failed'
...
sh: echosadf: command not found
success
>>>



More information about the Python-list mailing list