Search code examples
pythoninstanceattributeerror

AttributeError qsbk instance has no attribute 'stories'


my coding is as follows.

First is my class setting

class qsbk:
    # standalize some variables
    def __int__(self):
        self.stories = []
        self.pageIndex = 1
        self.user_agent = 'Mozilla/4.0(compatible;MS IE 5.5;Windows NT)'
        #standalize headers
        self.headers = {'User-Agent': self.user_agent}
        self.enable = False

Then activate loadpage

def loadpage(self):
    if self.enable == True:
        if len(self.stories) < 2: 

The error is:

File "C:/Python27/webcapture2.py", line 41, in loadpage if len(self.stories) < 2:

AttributeError: qsbk instance has no attribute 'stories'


Solution

  • The constructor should be __init__ but you named it as __int__

    That might be the cause. Check it out