I'm trying to write a script that will parse IRC chat logs and color code them if it finds certain characters. I was able to make this work with one character, but to make it even more accurate I would like to use two identifying characters. Here is my code :
import urllib2 response = urllib2.urlopen("http://192.168.1.100:81/%23pi.log") tuna = response.readlines()[-10:] for j in tuna: for e,n in j: if e,n == "*"," ": j = "This: " + str.strip(j) + " will be Pink" elif e,n == "<","%": j = "This: " + str.strip(j) + " will be yellow" elif e,n == "<","@": j = "This: " + str.strip(j) + " will be dark pink" print(str.strip(j)) Obviously the "for e,n" business doesnt work, but I think it makes for some decent pseudocode for what I'm trying to accomplish. Here is some sample tuna: ['[7:55pm] <P0ke> My teachings goes back to the last iceage.\r\n', '[7:55pm] <%Zack> ahh now it does\r\n', '[7:55pm] <%Zack> ok\r\n', '[7:55pm] <P0ke> Or it is down just for you.\r\n', '[7:55pm] <@FC3> which one? that -12000 ice age or the one before\r\n', '[7:55pm] <P0ke> the earliest..\r\n', '[7:56pm] <P0ke> so.. 12000 quite long..\r \n', '[7:56pm] <@FC3> the one created by the meteor then\r\n', '[7:57pm] <P0ke> did not know that.. this is just a new teory I am folding.\r\n', '[7:57pm] * P0ke test test test\r\n'] -- http://mail.python.org/mailman/listinfo/python-list