Skip to content

Instantly share code, notes, and snippets.

@misja
Created August 31, 2011 12:30
Show Gist options
  • Save misja/1183424 to your computer and use it in GitHub Desktop.
Save misja/1183424 to your computer and use it in GitHub Desktop.
Set json data as an attribute in a tweepy Status object.
import tweepy
import json
@classmethod
def parse(cls, api, raw):
status = cls.first_parse(api, raw)
setattr(status, 'json', json.dumps(raw))
return status
tweepy.models.Status.first_parse = tweepy.models.Status.parse
tweepy.models.Status.parse = parse
@przemyslslaw
Copy link

Many thanks, very clean solution and works like a charm!

@guysoft
Copy link

guysoft commented Nov 28, 2012

Works, and also can be tweaked to return a dict with:
setattr(status, 'AsDict', raw)

similar to python-twitter (except its an attributive and not a method).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment