I just checked: you have to reload the file in interactive mode each time you want to test it out. So do the datafile = file('..') line again and then the for-loop code. Or better yet, make it a function, if you're up to that:
Code:
def check():
datafile = file('data.xml')
found = False
for line in datafile:
if '168439992' in line:
found = True
break
print found
And then run to test.

Originally Posted by
javierrivera
What about
:
Code:
datafile = file('data.xml')
'168439992' in datafile
Way more pythonic IMHO.
That does not appear to work.
Bookmarks