Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyList:
- def __init__(self, start=[]):
- print('__init__ method')
- self.list = list(start)
- if __name__ == '__main__':
- M = MyList([2,4,7,8,9,2,3,4])
- print(M.list)
- def __str__(self):
- return "__repr__ method: {0}".format(self.list)
- class MyList:
- def __init__(self, start=[]):
- print('__init__ method')
- self.list = list(start)
- def __repr__(self):
- return "__repr__ method: {0}".format(self.list)
- def __getattr__(self, item):
- print('__getattr__ method')
- return getattr(self.list, item)
- def __setattr__(self, key, value):
- print('__setattr__ method')
- if key == 'boolAttr':
- self.__dict__['boolAttr'] = False
- else:
- self.__dict__[key] = value
- if __name__ == '__main__':
- M = MyList([2,4,7,8,9,2,3,4])
- print(M.list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement