I'm trying to search words in a text with the function any()
of python, I was expecting the same behaviour for the two following, but it's not:
keyword_list=['WASHER', 'SCREW']
all_text = "test_string"
if any(word in all_text for word in keyword_list):
print "some of the strings found in str"
else:
print "no strings found in str"
if (True in (word in all_text for word in keyword_list)):
print "some of the strings found in str"
else:
print "no strings found in str"
running inside Spyder 2.2.0 with python 2.7.5(I downloaded the pythonXY package) the results are different from launching python with normal cmd console.
In fact result inside Spyder:
>>> runfile(r'C:\untitled0.py', wdir=r'C:\PythonTestbench')
some of the strings found in str
no strings found in str
In fact result inside command prompt:
>>> runfile(r'C:\untitled0.py', wdir=r'C:\PythonTestbench')
no strings found in str
no strings found in str
Has Spyder environment has another version of any()
function, as explained here.
How can I force to not use the function contained into NumPy?