[Tutor] returning the entire line when regex matches

Steve Willoughby steve at alchemy.com
Sun May 3 23:23:06 CEST 2009

Alan Gauld wrote:
>> if re.search != (r'Domains:', line):
> Because you are assigning a tuple containing a string and a line of text
> to a name which is currently bound to a function object (re.search)

Actually, he's COMPARING the two, not assigning.  But comparing a
function object and a tuple is still not going to do anything sensible.

> But if it is a simple string you are searching for regex is overkill and
> probably slower than using in.

This is good advice.  I was assuming that the question was about regex
and would be grown into a more complex pattern match in the final
application.  If all you really want to do is see if a constant text
string like "Domain:" is in a string, regex will work but is overkill.

More information about the Tutor mailing list