Methods uses method attributes of the self argument : Class self « Class « Python






Methods uses method attributes of the self argument

class Bag:
    def __init__(self):
        self.data = []
    def add(self, x):
        self.data.append(x)
    def addtwice(self, x):
        self.add(x)
        self.add(x)

a = Bag()

a.add(4)
           
       








Related examples in the same category