finding a substring

Skip Montanaro skip at pobox.com
Mon May 20 09:27:42 EDT 2002


    >>     line = sfile.readline(1024)
    ...
    >>      errorval = MESSAGE.find(line)

Assuming you intend to search for line in MESSAGE the second call is okay.
Note, however, that the line variable is likely to have a trailing newline.
You might want to strip() it first.

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
"Excellant Written and Communications Skills required" - seen on chi.jobs





More information about the Python-list mailing list