[PYTHON]

class T(object):

    #
    words = []

    def add_word(self,word):
        #
        self.words.append(word)


c = T()
c.add_word('add 1')
c.add_word('add 2')
print(c.words)#['add 1', 'add 2']

d = T()
d.add_word('add 3')
d.add_word('add 4')
print(d.words) #['add 1', 'add 2', 'add 3', 'add 4']

Recommended Posts