X-Git-Url: https://jfr.im/git/z_archive/twitter.git/blobdiff_plain/b8fd12068076e2be6bfb44ee1ff64c6f8fd8b497..249508919a85673ed16c9661815697aada5462b5:/twitter/stream.py diff --git a/twitter/stream.py b/twitter/stream.py index 2c60918..295e490 100644 --- a/twitter/stream.py +++ b/twitter/stream.py @@ -35,6 +35,21 @@ class TwitterStreamCall(TwitterCall): return iter(TwitterJSONIter(handle, uri, arg_data)) class TwitterStream(TwitterStreamCall): + """ + Interface to the Twitter Stream API (stream.twitter.com). This can + be used pretty much the same as the Twitter class except the + result of calling a method will be an iterator that yields objects + decoded from the stream. For example:: + + twitter_stream = TwitterStream(auth=UserPassAuth('joe', 'joespassword')) + iterator = twitter_stream.statuses.sample() + + for tweet in iterator: + ...do something with this tweet... + + The iterator will yield tweets forever and ever (until the stream + breaks at which point it raises a TwitterHTTPError.) + """ def __init__( self, domain="stream.twitter.com", secure=False, auth=None, api_version='1'):