I'm trying to extend a class, TwythonStreamer in twython. Followed: [Inheritance and Overriding __init__ in python. Redefining the on_success method which works fine. My problem is adding a count variable and initializing it to zero. I get the error "TypeError: init() takes exactly 1 argument (5 given)" because I'm messing up the init().
from twython import TwythonStreamer
C_KEY = "my_key"
C_SECRET = ""
A_TOKEN = ""
A_SECRET = ""
class MyStreamer(TwythonStreamer):
def __init__(self):
super(MyStreamer, self).__init__()
self.count = 0
def on_success(self, data):
if 'text' in data:
self.count += 1
print("found it.", self.count)
stream = MyStreamer(C_KEY, C_SECRET, A_TOKEN, A_SECRET)
stream.statuses.filter(track="Primary")