finding a substring

ian iwaters at btclick.com
Mon May 20 10:02:31 EDT 2002


hi im writing the a spam checking routine for
my mail server and i having basic problems
checking for a sub string in the message

the MESSAGE var is a line from a socket
and the line var is a line from a file
the routine wont find any substrings

any help would be great
cheers

print "Checking against spam file"
   sfile = file('spam.txt','r',1024)

   while 1:
    line = sfile.readline(1024)
    if line == '':break
    else:
     print MESSAGE
     errorval = MESSAGE.find(line)
     print str(errorval)
     if errorval == -1:
      print "Message OK"
     else:
      print "Message not OK"

                                print line
   sfile.close()






More information about the Python-list mailing list