I have two methods that should write to the same list.
class MySpider():
def parse_post(self, response):
commentList = []
...
commentList.append(someData)
def parse_comments(self, response):
commentList = []
...
commentList.append(someData)
In this code there are two commentList lists but I need a single list where I can append data. I want to access this list in any method of this class. I tried with
class MySpider():
commentNum = []
def parse_post(self, response):
...
commentList.append(someData)
def parse_comments(self, response):
...
commentList.append(someData)
But this gives me an error global name commentList is not defined. Any ideas how to have a single list that can be accessed in all methods in that class?