fork(1) download
  1. class line_type:
  2. def __init__(self, content, tabs):
  3. self.content = content
  4. self.tabs = tabs
  5.  
  6. def print_content(self):
  7. print('\t' * self.tabs, self.content, sep='')
  8.  
  9.  
  10. class lines_type(list):
  11. def __init__(self, lines):
  12. self.lines = lines[:]
  13.  
  14. def print_all_lines(self):
  15. for u in self.lines:
  16. u.print_content()
  17.  
  18. def remove(self, idx):
  19. self.lines.remove(self.lines[idx])
  20.  
  21.  
  22. line = line_type('ideone is the best online compiler', 2)
  23. line.print_content()
  24. print('-------------')
  25.  
  26. lines = []
  27. lines.append(line)
  28. lines.insert(1, line_type('fun', 3))
  29. lines.insert(1, line_type('fun2', 3))
  30. lines.insert(1, line_type('fun3', 3))
  31.  
  32. _lines = lines_type(lines)
  33. print(_lines)
  34. _lines.insert(0, line_type('bad', 1))
  35. _lines.print_all_lines()
  36. print('-------------')
  37. _lines.print_all_lines()
Success #stdin #stdout 0.02s 27704KB
stdin
Standard input is empty
stdout
		ideone is the best online compiler
-------------
[] 4
		ideone is the best online compiler
			fun3
			fun2
			fun
-------------
		ideone is the best online compiler
			fun3
			fun2
			fun