Advertisement
Guest User

Untitled

a guest
May 4th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. >>> l = [1,2,3,3,2,1,2,4]
  2. >>> set(l)
  3. set([1, 2, 3, 4])
  4.  
  5. lines_seen = set() # holds lines already seen
  6. outfile = open(outfilename, "w")
  7. for line in open(infilename, "r"):
  8. if line not in lines_seen: # not a duplicate
  9. outfile.write(line)
  10. lines_seen.add(line)
  11. outfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement