I'm trying to filter tweets by hashtag and output the text of the Tweet.
The class Tweet contains the overarching tweet info, of which I only need "text". I know that str method needs to be used to call each instance of the class, but down below when I "print", the above class is inaccessible. Please help :D
Edit: what's the implication of replacing __str__
with __repr__
in class Tweet? Thanks!
class Tweet():
tweet = Tweet()
def __init__(self, tweet_dict = {}):
if "statuses" in tweet_dict:
self.status = tweet_dict["statuses"]
else:
self.status = ""
if "text" in self.status:
self.text = item["text"]
else:
self.text = ""
def __str__(self):
tweet_info = self.text
return tweet_info
#-------------------------------------------------------------------
tweet_inst = []
for dic in statuses:
item_instances = Tweet(dic)
tweet_inst.append(item_instances)
print(tweet_inst)