Mega Code Archive

 
Categories / Python / Class
 

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)