I have if statement
if "1111111" in players or "0000000" in players or "blablabla" in players: do something How to write in short ?
if any(a in players for a in list_of_tests): #something pass If you are using numpy.any(), you will need to convert the generator to a list first.
if np.any([a in players for a in list_of_tests]): #something pass any played nice with generators. I am used to using numpy.any which I am pretty sure does not.numpy.any should work as well. All you're doing is iterating until the first False.np.any (on 1.7) will return a generator if you pass it a generator. It makes assumptions about the input being array-like. Probably related to what you get if you do np.array(t for t in src) (which is an array with a single generator element).