Skip to content

Instantly share code, notes, and snippets.

@reidransom
Created June 3, 2011 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reidransom/1007273 to your computer and use it in GitHub Desktop.
Save reidransom/1007273 to your computer and use it in GitHub Desktop.
Pretty print wrapper for Python Twitter Tools.
#!/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