I got it. I was comparing '345' to '345\n'

Adding the '\n' to the slice did indeed do the trick.

#!/usr/bin/env python

import string

def main():
     infile = open("filex")
     outfile = open("results_testx", "w")
     zips = open("zippys", "r")
     match_zips = zips.readlines()
lines = [line for line in infile if (line[0:3] + '\n') in match_zips]
     outfile.write(''.join(lines))
#     print lines[0:2]
     zips.close()
     infile.close()
     outfile.close()
main()

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to