For a simple blog-to-twitter posting gateway (source code) I’m
relying on the excellent
A simplified version of my workflow would look like this:
def post(entry): title = entry.title print "posting [%s]" % title api.PostUpdate(title) # api is a twitter Api object feed = feedparser.parse(config["feed"]) for e in reversed(feed.entries): if not e.id in seen: post(e)
This code bombed out with an exception on the first post that had a non-ASCII title. Can you spot why?
Brend on #python pointed out to me that the issue is not, exactly,
title into a non-unicode string. Depending on
print u"posting [%s]" % title could help. In my case
however, I ran into the issue from cron with no locale set at all, so dumbing
the string down to ascii is still the right thing to do.