I'm trying to access a class from another class but I'm running into this issue.
This is the class I'm trying to access.
import tweepy
ckey= '**********************'
csecret= '**********************'
atoken= '**********************'
asecret= '**********************'
class TwtPrinter:
def printTweet(self, user, text):
auth = tweepy.OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
api = tweepy.API(auth)
for status in tweepy.Cursor(api.user_timeline).items():
try:
api.destroy_status(status.id)
except:
pass
And this is a scaled down version of the class where I'm having the error.
import sqlite3
import random
from app.models.monDAO import monDAO
from app.models.charDAO import CharDAO
from app.models.dunDAO import DunDAO
from app.controllers.twt_print import TwtPrinter
class GameManager:
def testDB(self):
print("hello world")
conn = sqlite3.connect('DunSuciRun.sqlite')
c = conn.cursor()
this = """SELECT * FROM CHARACTERS"""
c.execute(this)
getStuff = c.fetchall()
charTuple = getStuff[0]
cha = CharDAO(charTuple[0], charTuple[1],charTuple[2],charTuple[3],charTuple[4])
print(cha.name.split(' ')[0])
def test(self):
self.twt_print = TwtPrinter
testing = "testing"
print testing
# self.twt_print = TwtPrinter
self.twt_print.printTweet("1""2")
The error in question is this:
C:\Python27\python.exe C:/Users/Jensi/PycharmProjects/DSR.02/app/controllers/game_manager.py
Traceback (most recent call last):
File "C:/Users/Jensi/PycharmProjects/DSR.02/app/controllers/game_manager.py", line 14, in <module>
class GameManager:
File "C:/Users/Jensi/PycharmProjects/DSR.02/app/controllers/game_manager.py", line 241, in GameManager
test("")
File "C:/Users/Jensi/PycharmProjects/DSR.02/app/controllers/game_manager.py", line 32, in test
self.twt_print = TwtPrinter
AttributeError: 'str' object has no attribute 'twt_print'
Process finished with exit code 1