Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

mdb.py

By: a guest on Apr 13th, 2012  |  syntax: None  |  size: 0.35 KB  |  views: 65  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env python3.0
  2.  
  3. import codecs
  4.  
  5. filein = 'heads_of_state.txt'
  6. fileout = 'mdb.txt'
  7.  
  8. setHeads = set()
  9. for line in codecs.open(filein, 'r', 'utf-8'):
  10.     setHeads.add(line.strip())
  11. liHeads = sorted(setHeads, key=lambda a: (len(a), a))
  12. liHeads = filter(lambda a: len(a) > 4, liHeads)
  13. codecs.open(fileout, 'w', 'utf-8').write("\n".join(liHeads))