Given an if statement like:
if response.status == SUCCESS or \
response.status == FAILURE or \
response.status == CLEAR or \
response.status == READY:
Is it better to refactor like (1):
if any(response.status == status for status in (SUCCESS, FAILURE, CLEAR, READY):
Or (2):
if response.status in {SUCCESS, FAILURE, CLEAR, READY}:
My hunch is that 1 is better as it is more transparent (if not also more readable), but 2 is more concise and avoids having to iterate through each item in the tuple.
You could use tuple or list like this, no need to iterate. (Python3.7)
your case