1. 5
  1.  

  2. 3

    Alternatively use elif so you can tell at a glance that only one branch is executed.

    response = server.Call(request)
     
    if response.GetStatus() != RPC.OK:
      raise RpcError(response.GetStatus())
    elif not response.GetAuthorizedUser():
      raise AuthError('unauthorized')
    elif response.GetEnc() != 'utf-8':
      raise ValueError('wrong encoding')
    elif not response.GetRows():
            raise EmptyError()
    else:
            vals = [ParseRow(r) for r in 
                    response.GetRows()]
            avg = sum(vals) / len(vals)
            return avg, vals