Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in reponse code checking due to operator precedence #2

Open
solarjoe opened this issue Apr 25, 2022 · 1 comment
Open

Error in reponse code checking due to operator precedence #2

solarjoe opened this issue Apr 25, 2022 · 1 comment

Comments

@solarjoe
Copy link

This check does not work as expected as is always True:

if response.status_code == 200 or 201:

if response.status_code == 200 or 201:

Because Python reads it as if (response.status_code == 200) or 201

https://docs.python.org/3/reference/expressions.html#operator-precedence

@solarjoe
Copy link
Author

You would write is as if response.status_code in [200, 201]:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant