I'm brand new to classes in python, I have my function to call tweets based on a keyword and analyze their sentiment values. Here is the class code:
def searchForKeyword(self, x, z):
a = []
s = 0
public_tweets = api.search(x, count = z)
for tweet in public_tweets:
analysis = TextBlob(tweet.text)
a.append(s)
a[s] = analysis.sentiment
print(a[s])
s = s + 1
print("succesful")
Here is where I am calling the class(don't know if I'm doing this right, I'm new to python and programming in general):
import tweepy
from textblob import TextBlob
from myfuncs import myfuncs as m
m.searchForKeyword('capitals', 50)
When I run the code in the terminal it reads:
unbound method searchForKeyword() must be called with myfuncs instance as first argument (got str instance instead)
I've done some searching and I haven't found anything that works, I'm a bit stumped! Thank You! For some reason, I can't get the code for the beginning of the class to paste at the top so here it is:
import tweepy
from textblob import TextBlob
class myfuncs:
def __init__(self, consumer_key, consumer_secret, access_token, access_toekn_secret, auth, api):
self.consumer_key = 'ur7LPai7hD8nYw9CMlQ8exgEO'
self.consumer_secret = 'mak7uBwYNucDIhF4lPIfy4JMIEIaVM9Dx0zgEo2LYwru7UDHPi'
self.access_token = '816453418235600896-jvDVIfnewq6oJzYIbDFh7vvI9vfMd2I'
self.access_token_secret = 'kqJFFHCJMA1mWQmg2XFPvFSnRGasxx4CgxhNVY3vZIweh'
self.auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
self.api = tweepy.API(auth)