tomdodd4598

Untitled

May 14th, 2021
754
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Item:
  2.     _next = None
  3.    
  4.     def __init__(self, value, method_container):
  5.         self.value = value
  6.         self.method_container = method_container
  7.    
  8.     def __len__(self):
  9.         item = self
  10.         i = 1
  11.         while True:
  12.             if item == None:
  13.                 return i
  14.             else:
  15.                 item = start[i].print_get_next()
  16.                 i += 1
  17.    
  18.     def __getitem__(self, n):
  19.         item = self
  20.         for i in range(n):
  21.             item = item._next
  22.         return item
  23.    
  24.     def __iter__(self):
  25.         return self
  26.    
  27.     def __next__(self):
  28.         item = self._next
  29.         if item == None:
  30.             raise StopIteration
  31.         else:
  32.             return item
  33.    
  34.     def insertBefore(self, other):
  35.         return method_container.insert_before(this, other)
  36.    
  37.     def valueEquals(self, value):
  38.         return method_container.value_equals(this, value)
  39.    
  40.     def print_get_next(self):
  41.         print(value, end = "")
  42.         print("\n" if _next == None else ", ", end = "")
  43.         return _next
RAW Paste Data