Changeset 540
- Timestamp:
- 05/16/03 16:06:45 (6 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBFoundation/RBFoundation/Objects/NestedOperations.py
r539 r540 36 36 37 37 name = '?' 38 _next = None38 next = None 39 39 40 40 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 45 45 if name is not None: 46 46 self.name = name 47 self._next = next 47 if next is not None: 48 self.next = next 49 next.OnAddNestedOp(self) 48 50 for n, v in kw.iteritems(): setattr(self, n, v) 49 51 … … 52 54 53 55 def __iter__(self): 54 next = self ._next56 next = self 55 57 while next: 56 58 yield next 57 next = next. _next59 next = next.next 58 60 59 61 def __getitem__(self, idx): … … 63 65 try: 64 66 itr = iter(self) 65 for each in range(0, idx, -1):67 for i in range(1, idx, -1): 66 68 result = itr.next() 67 69 return result … … 70 72 else: 71 73 results = list(iter(self)) 74 results.reverse() 72 75 return results[idx] 76 77 def OnAddNestedOp(self, nestedop): 78 pass 73 79 74 80 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 113 119 assert op.result == shouldbe**2 114 120 print op, op.value, op.result 121 122 firstop = result[-1] 123 124 assert firstop[-1] is result[-2] 125 assert firstop[-2] is result[-3] 126 assert firstop[-3] is result[-4] 127 assert firstop[-4] is result[-5] 128 assert firstop[-5] is result[-6] 129 130 assert firstop[0] is result[0] 131 assert firstop[1] is result[1] 132 assert firstop[2] is result[2] 133 assert firstop[3] is result[3] 134 assert firstop[4] is result[4] 135 assert firstop[5] is result[5]
