Is there an advantage to using callbacks and context sharing instead of Python generators? My sense is that judicious use of yield lets you simplify the approach but perhaps I am missing something.

#import TweetBot # for more on Python generators see: # def tweet_feeder(file_name = 'tweets.txt'): with open(file_name) as in_file: tweets = tweets.reverse() # so we can pop them off for tweet in tweets: yield tweet print('Finished processing tweets!') if __name__ == '__main__': for tweet in tweet_feeder('tweets.txt'): print(tweet) #TweetBot.tweet(tweet)