Nick Burgess wrote: > How do I make this code print lines NOT containing the string 'Domains'? > > > import re > for line in log: > if re.search (r'Domains:', line): > print line > > > This does not work... > > if re.search != (r'Domains:', line):
re.search (r'Domains:', line) is a function call which (simplifying slightly here) returns a true value if <line> matches the regex "Domains:". It might make it more clear if you leave out the extra space there (because I think you're getting confused thinking re.search and (...) are two separate expressions since you put != between them): re.search(r'Domains:', line) If you want to print lines which do NOT match, try this: if not re.search(r'Domains:', line): print line _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor