Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Number(object):
- list = []
- def extend(self,arg):
- self.list.extend(arg.list)
- def multi(arg):
- cls = Number()
- tmp = []
- file = open('data.txt', 'r')
- for line in file:
- tmp.append(int(line))
- file.close
- print(tmp)
- file = open('data.txt', 'w')
- file.write('')
- file.close
- for item in tmp:
- cls.extend(multi(item))
- cls.list.append(arg)
- print ('arg:',arg,' cls.list:',cls.list," id of cls:",id(cls))
- return cls
- def main():
- ans = multi(5)
- print('ans.list:',ans.list)
- if __name__ == '__main__':
- main()
- 5
- 4
- 3
- 2
- 1
- class Number(object):
- num = 5
- def multi(arg):
- num_cls = Number()
- if arg > 1:
- num_cls.num = arg * multi(arg - 1)
- else:
- num_cls.num = 1
- print ('arg:',arg,' num:',num_cls.num," id of num_cls:",id(num_cls))
- return num_cls.num
- def main():
- ans = multi(5)
- print (ans)
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment