[Tutor] Confirmation if command worked

Alan Gauld alan.gauld at btinternet.com
Thu Aug 25 10:19:49 CEST 2011

On 25/08/11 07:25, Christian Witts wrote:

> Once you call child.close() the exit and signal status will be stored in
> .exitstatus and .signalstatus, for a normal exit of the program
> .exitstatus will store the return code from SCP as per [1] [2] [3] and
> .signalstatus will be None.  If SCP was terminated with a signal then
> .exitstatus will be None and .signalstatus will contain the signal
> value.  Info found in the docs [4].
>      data = child.read()
>      child.close()
>      if child.exitstatus and child.exitstatus == 0:
>          success = True
>      else:
>          success = False

Won't that if statement always evaluate to false?

If exitstatus is 0 the first part of the and will be false and so the 
entire and expression is false.

If exitstatus is not 0 then the second part of the and will be false and 
again the and result will be false.

Did you mean to use exitstatus for both tests?

Or am I missing something subtle here?

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list