Httpx: Is it planned to implement __bool__ on Response?

Created on 10 Feb 2020  Â·  2Comments  Â·  Source: encode/httpx

The same way it's done on requests.

I saw that response.is_error is available, I was wondering if it was planned or not (as I was considering httpx some kind of drop-in replacement for requests)?

Thanks again

question

Most helpful comment

I'm inclined towards a "no" too, basically for the same reason we don't have response.ok: ambiguous — and in this case, possibly error-prone.

(Eg. if you use if not response: ... would that be to check whether response is set, or whether the response is "falsy"? What would "falsy" mean? response.is_error? Then we should access this attribute explicitly.)

All 2 comments

Nope, I doubt we’d do that.

I'm inclined towards a "no" too, basically for the same reason we don't have response.ok: ambiguous — and in this case, possibly error-prone.

(Eg. if you use if not response: ... would that be to check whether response is set, or whether the response is "falsy"? What would "falsy" mean? response.is_error? Then we should access this attribute explicitly.)

Was this page helpful?
0 / 5 - 0 ratings