I wrote a script in python that parses some strings.
The problem is that I need to check if the string contains some parts. The way I found is not smart enough.
Here is my code:
if ("CondA" not in message) or ("CondB" not in message) or ("CondC" not in message) or ...:
Is there a way to optimize this? I have 6 other checks for this condition.
Use a generator with
any()
orall()
:In Python 3, you could also make use of
map()
being lazy: