Skip to content

Instantly share code, notes, and snippets.

@dougluce
Last active July 6, 2016 21:34
Show Gist options
  • Save dougluce/5ed9d4a497302eda9c51abf31900105b to your computer and use it in GitHub Desktop.
Save dougluce/5ed9d4a497302eda9c51abf31900105b to your computer and use it in GitHub Desktop.
Python Got Too Big
from email.header import decode_header
import sys,re
for line in sys.stdin:
if re.match('(From|Subject|To): ', line):
dh = decode_header(line)
print ' '.join([unicode(t[0], t[1] or 'ASCII') for t in dh])
from email.header import decode_header
import sys,re
x = 0
for line in sys.stdin:
if re.match('(From|Subject|To): ', line):
dh = decode_header(line)
print ' '.join([unicode(t[0], t[1] or 'ASCII') for t in dh])
x += 1
if x == 3:
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment