如何在两个类中使用相同的变量

Zey*_*nel 0 python

# I have this class:

class Test(webapp.RequestHandler):
    myList = []
    def get(self):
        s = [self.request.get('sentence')]
        self.myList.append(s)
        htmlcode1 = HTML.table(self.myList)
        myListLen = len(self.myList)
        lastItem = self.myList[myListLen-2]

# I want to add the following to delete the contents of `myList` when I enter 'delete' in the form:

class Delete(webapp.RequestHandler):
    def get(self):
        if s == ['delete']:
            del self.myList[:]
Run Code Online (Sandbox Code Playgroud)

我怎么用self.myListDelete()

D.C*_*.C. 6

你会想要使用

Test.myList
Run Code Online (Sandbox Code Playgroud)

因为myList是类的属性,而不是该类的特定实例.