How to use shell return value like $? In python?

aaabbb16 at hotmail.com aaabbb16 at hotmail.com
Sun Oct 23 22:51:47 EDT 2011


On Oct 23, 7:44 pm, aaabb... at hotmail.com wrote:
> exp:
> os.system('ls -al')
> #I like to catch return value after this command. 0 or 1,2,3....
> does python support to get "$?"?
> then I can use something like:
>  If $?==0:
>      ........
> ................
> TIA
> david

So for what I do is:
r_number =os.system('ls -al')
     if r_number == 0
      .........
      .........
any other way?



More information about the Python-list mailing list