Advertisement
molnarjani

Untitled

May 30th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. class Tetel():
  2. def __init__(self, f):
  3. # input file
  4. self.f = f
  5.  
  6. def _process_data(fl):
  7. data = []
  8. with open(fl) as f:
  9. for sz in f:
  10. data.append(int(sz))
  11. return data
  12.  
  13. def _get_max(data):
  14. """returns maximum of a list"""
  15. return max(data)
  16.  
  17. def _get_sum(data):
  18. """returns sum of a list"""
  19. return sum(data)
  20.  
  21. def _filter_data(data, f):
  22. """returns elements of a list that return True to a function"""
  23. return [elem for elem in data if f(elem)]
  24.  
  25. self.data = _process_data(self.f)
  26. self.get_max = _get_max
  27. self.get_sum = _get_sum
  28. self.filter_data = _filter_data
  29.  
  30. def osszegez(self):
  31. """returns sum"""
  32. return self.get_sum(self.data)
  33.  
  34. def maxker(self):
  35. """returns max"""
  36. return self.get_max(self.data)
  37.  
  38. def feltmaxker(self, f):
  39. """returns max of filter_data's returned list"""
  40. return self.get_max(self.filter_data(self.data, f))
  41.  
  42. def szamlal(self, f):
  43. """returns length of filter_data's returned list"""
  44. return len(self.filter_data(self.data, f))
  45.  
  46. print dir(Tetel("in"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement