Created
June 3, 2011 22:18
-
-
Save reidransom/1007273 to your computer and use it in GitHub Desktop.
Pretty print wrapper for Python Twitter Tools.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import subprocess | |
import pprint | |
import textwrap | |
def chunks(l, n): | |
""" Yield successive n-sized chunks from l. | |
""" | |
for i in xrange(0, len(l), n): | |
yield l[i:i+n] | |
#pprint.pprint(list(chunks(range(75), 10))) | |
p = subprocess.Popen( | |
'/usr/local/Cellar/python/2.7.1/bin/twitter', | |
shell = True, | |
stdout = subprocess.PIPE, | |
stderr = subprocess.STDOUT, | |
) | |
feed = p.stdout.readlines()[-5:] | |
feed.reverse() | |
for tweet in feed: | |
paragraph = textwrap.wrap(tweet, 80) | |
print paragraph.pop(0) | |
for line in paragraph: | |
print ' ' + line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment